Take the 2-minute tour ×

I have a school project in Java assigned to do the following:

Write an application to be used in a college admission's office. To be admitted to this school, the student must have either: •A grade point average of 3.0 or higher and an entrance score of 60 or higher •An entrance score of 85 or higher and any grade point average To make things more user friendly, write some code to do some error checking of the data.
That is, if the grade point average is not between 0.0 and 4.0 or if the entrance score is not between 0 and 100, then print an appropriate error message to the screen telling the user that they entered invalid data. Use the above criteria to write a procedure called, accepted, that takes the grade point average and entrance score as parameters and returns no value. This procedure will print either "Accept" or "Reject", accordingly. Finally, write a main procedure that prompts the user for a grade point average and an entrance score. This procedure should then call the accepted method to display the result.

Although I foolishly wrote the following code below without thoroughly reading the directions. My problem is I am not sure how call a procedure. Also how do I pass variables to this called procedure? Any help or other examples would be helpful. Below is the code I written while it works it doesn't feature an Accept procedure that gets called.

import java.util.Scanner;
class College {

    public static void main(String[] args) {
         double testGPA;
         int testScore;

        Scanner input = new Scanner(System.in);
        System.out.println("Welcome to Student Admisions");
        System.out.println("Please student prospects GPA: ");
        testGPA = input.nextDouble();

        System.out.println("Now enter prospect students Test Score: ");
        testScore = input.nextInt();

        if (testGPA >= 0.0 && testGPA <= 4.0 && testScore >= 0 && testScore <= 100){
            if(testGPA >= 3.0 && testScore >= 60 || testScore >= 85){
                System.out.println("Student is ACCEPTED to university!");
                System.out.println("Students GPA is a " + testGPA + " and students test score is a " + testScore + "%");
            else {
                System.out.println("Student is NOT ACCEPTED to university!");
            System.out.println("Please Check GPA and Test score input!");
            System.out.println("Your inputs were:");
            System.out.println(testGPA + " = GPA should be between 0.0 and 4.0.");
            System.out.println(testScore + " = Test Score should be between 0 and 100");
share|improve this question
I'm somewhat sceptical of an assignment which requires you to write a "procedure" in Java (rather than a method, the normal terminology) but if you really don't know how to declare a method with parameters, I would strongly suggest that SO shouldn't be your starting point. Ask your teachers for help, or read a Java book from the start. –  Jon Skeet Jan 22 '11 at 18:48

1 Answer 1

up vote 0 down vote accepted

A very simple procedure call demo here.

public class Demo {
    private static void prn(int x) {
    public static void main(String[] args) {

Got it?

share|improve this answer
You have spelled 'class' with capital c –  Elijah Saounkine Jan 22 '11 at 19:05
Thank you. My mistake. –  Haozhun Jan 22 '11 at 19:06
I got it that really helps clear it up. Thanks so much. Done with my program and its working great now! –  allencoded Jan 22 '11 at 19:28

Your Answer


