We assume that there are 5 students in this class.
The application creates two arrays to store students’ name and students’ grades. The names of the arrays are name and grade respectively.
The application asks the user to enter five students’ name, students’ midterm scores, and final scores. To take care of the repeated work, the application utilizes loop(s). The students’ names are stored to the name array.
4.The application calls (invokes) a method and the method name is average. The method “average” has two parameters for the midterm score and the final score of a student. The method returns the average of the scores.
The application calls (invokes) a method and the method name is function. The method “function” has two parameters: one is the average which is computed in 4) and the other is the final score. The method returns the higher score between two scores.
The application calls (invokes) a method and the method name is function. The method “function” has one parameter for the highest score in 5). The method returns the grade.
7.The grades are stored to the grade array.
− If the highest score is greater than 90, A will be returned. − If the highest score is greater than 80, B will be returned. − If the highest score is greater than 70, C will be returned. − If the highest scores is less than or equal to 70, F will be returned.
I dont know where to go from here... can anyone please help?
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double midterm =0,total = 0;
int i = 0;
double sum=0;
String name;
while (i < 5) {
System.out.println("Student");
System.out.println("Enter the Name of the Student: ");
name = input.nextLine();
System.out.println("Enter the Midterm Score: ");
midterm = input.nextDouble();
input.nextLine();
System.out.println("Enter the Final Score: ");
int number = input.nextInt();
input.nextLine();
total = midterm + number;
sum += total;
i++;
}
}
}
Aucun commentaire:
Enregistrer un commentaire