Temporarily Storing data
I'm writing a program that reads input grades for different students, so far i've written the program to gather input for one student. Whats a good method to gather the same info on another student. Is there someway i can constantly change the variables as new data is input?
My program so far:
import java.util.*;
publicclass AssignmentFour
{
private String studentName;
privateint quizzesScore, midtermScore, finalScore;
privatedouble overallScore;
privatechar finalGrade;
publicvoid readInput()
{
Scanner keyboard =new Scanner(System.in);
System.out.println("What is the name of the student?");
studentName = keyboard.nextLine();
System.out.println("What is the student's score in quizzes? (worth 20% of overall grade)");
quizzesScore = keyboard.nextInt();
while (quizzesScore < 0)
{
System.out.println("Score cannot be negative. (worth 40% of overall grade)");
System.out.println("Reenter the score for quizzes");
quizzesScore = keyboard.nextInt();
}
System.out.println("What was the student's midterm score? (worth 40% of overall grade)");
midtermScore = keyboard.nextInt();
while (midtermScore < 0)
{
System.out.println("Score cannot be negative.");
System.out.println("Reenter the score for the midterm");
midtermScore = keyboard.nextInt();
}
System.out.println("What was the student's score on the final?");
finalScore = keyboard.nextInt();
while (finalScore < 0)
{
System.out.println("Score cannot be negative.");
System.out.println("Reenter the score for quizzes");
finalScore = keyboard.nextInt();
}
overallScore = (quizzesScore*.2)+(midtermScore*.4)+(finalScore*.4);
if (overallScore >= 90)
finalGrade ='A';
elseif (overallScore >= 80)
finalGrade ='B';
elseif (overallScore >= 70)
finalGrade ='C';
elseif (overallScore >= 60)
finalGrade ='D';
else
finalGrade ='E';
}
publicvoid set(String newName,int newQuizzes,int newMidterm,int newFinal,double newOverall,char newGrade)
{
newName = studentName;
newQuizzes = quizzesScore;
newMidterm = midtermScore;
newFinal = finalScore;
newOverall = overallScore;
newGrade = finalGrade;
}
public String getName()
{
return studentName;
}
publicint getQuiz()
{
return quizzesScore;
}
publicint getMid()
{
return midtermScore;
}
publicint getFinal()
{
return finalScore;
}
publicdouble getOverall()
{
return overallScore;
}
publicchar getGrade()
{
return finalGrade;
}
publicvoid writeOutput()
{
System.out.println("The student's name is: " + studentName);
System.out.println("The student's quiz grade is: " + quizzesScore);
System.out.println("The student's midterm grade is: " + midtermScore);
System.out.println("The student's final exam grade is: " + finalScore);
System.out.println("The student's overall score is: " + overallScore);
System.out.println("The student's grade is: " + finalGrade);
}
}

