帮助介绍Java过程调用

时间:2011-01-22 18:45:27

标签: java call procedure

我在Java中有一个学校项目,负责执行以下操作:

  

编写要在a中使用的应用程序   大学录取办公室。成为   考上这所学校的学生   必须有:•成绩点   平均3.0或更高和一个   入学分数为60或更高•安   入学成绩为85分或更高   平均成绩要做事   更加用户友好,写一些代码   对数据进行一些错误检查   也就是说,如果平均分为平均分   不在0.0和4.0之间或如果   入口分数不在0到0之间   100,然后打印一个适当的错误   消息到屏幕告诉用户   他们输入了无效数据。使用   写上面的标准   程序被称为,接受,需要   平均分和入学分数   得分为参数并返回否   值。此程序将打印   “接受”或“拒绝”,   因此。最后,写一个主要的   提示用户输入的过程   平均成绩和入口   得分了。那么这个程序应该   调用接受的方法来显示   结果。

虽然我在没有仔细阅读说明的情况下愚蠢地写下面的代码。我的问题是我不确定如何调用程序。另外如何将变量传递给此调用过程?任何帮助或其他示例都会有所帮助。下面是我编写的代码,它没有被调用的Accept过程。

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();
        System.out.println("-----------------------");

        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("Students GPA is a " + testGPA + " and students test score is a " + testScore + "%");
            }
        }
        else{
            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");
        }
    }
}

1 个答案:

答案 0 :(得分:0)

这里有一个非常简单的程序调用演示。

public class Demo {
    private static void prn(int x) {
        System.out.println(x);
    }
    public static void main(String[] args) {
        prn(2);
        prn(3);
    }
}

知道了吗?