I need help too figure out how to get the numbers 8, 9, 76,99 comment out of the code so when i run the program, that the user can input their own numbers.
public class StudentRecordDemo {
/**
* StudentRecordDemo main() is used to validate and verify
* that all of the methods and data members of the class
* do or contain what they are supposed.
*/
public static void main(String[] args) {
StudentRecord g1 = new StudentRecord();
g1.set(8, 9, 76, 99);
g1.writeOutput();
System.out.println("StudentRecordDemo done.");
}
public class StudentRecord {
// data members:
private int quiz1;
private int quiz2;
private int midterm;
private int finalExam;
private float finalGrade;
private char letterGrade;
// data methods:
/**
* StudentRecord.set() allows for the direct unverified input of data
* members of the class for use in testing and setting values.
*/
public void set(int q1, int q2, int mt, int fE) {
quiz1 = q1;
quiz2 = q2;
midterm = mt;
finalExam = fE;
finalGrade = computeFinalGrade();
letterGrade = computeLetterGrade();
}
public void writeOutput() {
System.out.println("Quiz 1 = " + quiz1);
System.out.println("Quiz 2 = " + quiz2);
System.out.println("Midterm Exam= " + midterm);
System.out.println("Final Exam = " + finalExam);
System.out.println("Final Grade = " + finalGrade + " or an ["
+ letterGrade + "]");
}
/**
* StudentRecord.computeFinalGrade() takes all test scores and provides the
* final computed class grade.
*/
private float computeFinalGrade() {
double tempGrade = 0.125 * (quiz1 * 10); // first quiz part
tempGrade += 0.125 * (quiz2 * 10); // second quiz part
tempGrade += 0.25 * midterm; // midterm part
tempGrade += 0.50 * finalExam; // final exam part
return (float) tempGrade;
}
/**
* StudentRecord.computeLetterGrade() provides correct letter grade for the
* final grade provided.
*/
private char computeLetterGrade()
{
char tempGrade = '?';
if (finalGrade >= 89.5)
tempGrade = 'A';
else if (finalGrade >= 79.5)
tempGrade = 'B';
else if (finalGrade >= 69.5)
tempGrade = 'C';
else if (finalGrade >= 59.5)
tempGrade = 'D';
else
tempGrade = 'F';
return tempGrade;
}
}