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.
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.
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.
I have been able to do steps 1-4 [i think anyway] but now i am stuck....does anyone know where to go from here?
Scanner input = new Scanner(System.in);
double total = 0;
int i = 0;
int noOfStudents = 5;
String[] name = new String[noOfStudents];
double[] midScore = new double[noOfStudents];
double[] finalScore = new double[noOfStudents];
double[] number = new double[noOfStudents];
while (i < noOfStudents) {
System.out.println("Student");
System.out.println("Enter the Name of the Student: ");
name[i] = input.nextLine();
System.out.println("Enter the Midterm Score: ");
midScore[i] = input.nextDouble();
input.nextLine();
System.out.println("Enter the Final Score: ");
finalScore[i] = input.nextDouble();
input.nextLine();
total= midScore[i] + finalScore[i];
number[i] += total;
i++;
}
for(int a =0; a<noOfStudents; a++)
{
double average = number[a]/2.0;
}
System.out.println("Name\t\tGrade");
Aucun commentaire:
Enregistrer un commentaire