The program will compute the final grades of students. Each students holds the record of his/her Midterm grade, Second Quarter grade and Final exam. Final Grade will be 25% of Midterm grade, 30% of Second Quarter grade and 45% of the Final exam. The program will ask data for 10 student. Data for each Student consist of name, section, midterm grade, second quarter grade and final exam.
How will I display the grades of the student in a tabular form?
This is the code for gradesummary.java
public class gradesummary {
public static void main(String args[]){
Scanner cin = new Scanner(System.in);
Vector<Student> list = new Vector<>();
for(int x=0; x<10 ;x++){
Student s = new Student();
System.out.print("Name: ");
s.name = cin.nextLine();
System.out.print("Section: ");
s.section = cin.nextLine();
System.out.print("Midterm Grade: ");
s.midgrade = cin.nextDouble();
System.out.print("Second Quarter: ");
s.secondqtr = cin.nextDouble();
System.out.print("Final Exam: ");
s.finexam = cin.nextDouble();
//save s in data collection
list.add(s);
}
for(int x = 0; x<10; x++){
//what will i do here next?
Student xtt = list.get(x);
}
}
}
This is the code for Student.java
public class Student {
//is this class correct?
String name;
String section;
Double midgrade;
Double secondqtr;
Double finexam;
Double fingrade;
public Student(){
}
public Student (String n, String s, Double mg, Double sq, Double fe, Double fg){
name = n;
section = s;
midgrade = mg;
secondqtr = sq;
finexam = fe;
fingrade = fg;
}
}
i want an output like this
Name Midterm Grade Second Quarter Final Exam Final Grade
Student2 80 79.69 85 87.674
Student2 78 77.69 81 79.257
Student3 88 87 89 88.15
Student4 88.67 84 86.78 86.4185
Student5 98 90 94 93.8
Student6 93 91 90 91.05
Student7 84 78 87 83.55
Student8 82 86.4 89 86.47
Student9 72 79 81 78.15
Student10 85.34 81 83 82.985