Create a program to enter grades and calculate averages and letter grades. Need
ID: 655237 • Letter: C
Question
Create a program to enter grades and calculate averages and letter grades.
Need a class which will contain:
Student Name
Student Id
Student Grades (an array of 3 grades)
A constructor that clears the student data (use -1 for unset grades)
Get functions for items a, b, and c, average, and letter grade
Set functions for items a, n, and c
Note that the get and set functions for Student grades need an argument for the grade index.
Need another class which will contain:
An Array of Students (1 above)
A count of number of students in use
You need to create a menu interface that allows you to:
Add new students
Enter test grades
Display all the students with their names, ids, test grades, average, and letter grade
Exit the program
Add comments and use proper indentation.
Nice Features:
I would like that system to accept a student with no grades, then later add one or more grades, and when all grades are entered, calculate the final average or grade.
I would like the system to display the students in alphabetical order (no matter what order they are entered in)
An example menu might be:
Enter A to Add Students
Enter B to Enter Test Grades
Enter C to Display Results
Enter D to Exit Program
Please select A, B, C, or D:
Explanation / Answer
package grade; import javax.swing.*; public class Grade { private static String outputStr; public static void main(String[]args) { int A,B,C,D,E,a,b,c,d,e,t,w,x,y,z; double average1,average2,average3; char A,B,C,D,F,Grade1,Grade2,Grade3; String student1Str,student2Str,student3Str,AStrBStr,CStr,D4StrEStr,aStr,bStr,cStr,dStr,eStr,tStr,wStr,xStr,yStr,zStr; { student1Str=JOptionPane.showInputDialog("Enter first student's name: "); student2Str=JOptionPane.showInputDialog("Enter second student's name: "); student3Str=JOptionPane.showInputDialog("Enter third student's name: "); AStr=JOptionPane.showInputDialog("Enter the first score of the first student: "); A=Integer.parseIntAStr); BStr=JOptionPane.showInputDialog("Enter the second score of the first student: "); B=Integer.parseIntBStr); CStr=JOptionPane.showInputDialog("Enter the third score of the first student: "); C=Integer.parseInt(CStr); DStr=JOptionPane.showInputDialog("Enter the fourth score of the first student: "); D=Integer.parseInt(DStr); EStr=JOptionPane.showInputDialog("Enter the fifth score of the first student: "); E=Integer.parseInt(EStr); average1=A+B+C+D+E)/5; { if(average1>=90) Grade1='A'; else if(average1>=80) Grade1='B'; else if(average1>=70) Grade1='C'; else if(average1>=60) Grade1='D'; else Grade1='F'; } } { aStr=JOptionPane.showInputDialog("Enter the first score of the second student: "); a=Integer.parseInt(aStr); bStr=JOptionPane.showInputDialog("Enter the second score of the second student: "); b=Integer.parseInt(bStr); cStr=JOptionPane.showInputDialog("Enter the third score of the second student: "); c=Integer.parseInt(cStr); dStr=JOptionPane.showInputDialog("Enter the fourth score of the second student: "); d=Integer.parseInt(dStr); eStr=JOptionPane.showInputDialog("Enter the fifth score of the second student: "); e=Integer.parseInt(eStr); average2=(a+b+c+d+e)/5; { if(average2>=90) Grade2='A'; else if(average2>=80) Grade2='B'; else if(average2>=70) Grade2='C'; else if(average2>=60) Grade2='D'; else Grade2='F'; } } { tStr=JOptionPane.showInputDialog("Enter the first score of the second student: "); t=Integer.parseInt(tStr); wStr=JOptionPane.showInputDialog("Enter the second score of the second student: "); w=Integer.parseInt(wStr); xStr=JOptionPane.showInputDialog("Enter the third score of the second student: "); x=Integer.parseInt(xStr); yStr=JOptionPane.showInputDialog("Enter the fourth score of the second student: "); y=Integer.parseInt(yStr); zStr=JOptionPane.showInputDialog("Enter the fifth score of the second student: "); z=Integer.parseInt(zStr); average3=(t+w+x+y+z)/5; { if(average3>=90) Grade3='A'; else if(average3>=80) Grade3='B'; else if(average3>=70) Grade3='C'; else if(average3>=60) Grade3='D'; else Grade3='F'; } } outputStr="Name: "+student1Str+" "+"Average: "+average1+" "+"Grade: "+Grade1+" Name: "+student2Str+" "+"Average: "+average2+" "+"Grade: "+Grade2+" Name: "+student3Str+" "+"Average: "+average3+" "+"Grade: "+Grade3; JOptionPane.showMessageDialog(null,outputStr,"Grade",JOptionPane.PLAIN_MESSAGE); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.