import java.util.*;
public class PA4
{
private double quiz1, quiz2, midterm, cFinal, overallScore;
private char letterGrade;
public void readInput()
{
Scanner keys = new Scanner(System.in);
do
{
System.out.println("Enter Quiz 1 score from 1 to 10: ");
quiz1 = keys.nextInt();
if(quiz1 < 0 || quiz1 > 10)
System.out.println("Error. Invalid entry.");
}while(quiz1 < 0 || quiz1 > 10);
do
{
System.out.println("Enter Quiz 2 score from 1 to 10: ");
quiz2 = keys.nextInt();
if(quiz2 < 0 || quiz2 > 10)
System.out.println("Error. Invalid entry.");
}while(quiz2 < 0 || quiz2 > 10);
do
{
System.out.println("Enter Midterm score from 1 to 100: ");
quiz2 = keys.nextInt();
if(midterm < 0 || midterm > 100)
System.out.println("Error. Invalid entry.");
}while(midterm < 0 || midterm > 100);
do
{
System.out.println("Enter Final score from 1 to 100: ");
quiz2 = keys.nextInt();
if(cFinal < 0 || cFinal > 100)
System.out.println("Error. Invalid entry.");
}while(cFinal < 0 || cFinal > 100);
}
public void setGrades(double newQuiz1, double newQuiz2, double newMidterm, double newCFinal)
{
if (newQuiz1 >= 0)
quiz1 = newQuiz1;
else
{
System.out.println("Error. Invalid score.");
System.exit(0);
}
if (newQuiz2 >= 0)
quiz2 = newQuiz2;
else
{
System.out.println("Error. Invalid score.");
System.exit(0);
}
if (newMidterm >= 0)
midterm = newMidterm;
else
{
System.out.println("Error. Invalid score.");
System.exit(0);
}
if (newCFinal >= 0)
cFinal = newCFinal;
else
{
System.out.println("Error. Invalid score.");
System.exit(0);
}
}
public double getQuiz1()
{
return quiz1;
}
public double getQuiz2()
{
return quiz2;
}
public double getMidterm()
{
return midterm;
}
public double getCFinal()
{
return cFinal;
}
public void writeOutput()
{
System.out.println("Quiz 1 score: " + quiz1 + " %.");
System.out.println("Quiz 2 score: " + quiz2 + " %.");
System.out.println("Midterm score: " + midterm + " %.");
System.out.println("Final score: " + cFinal + " %.");
}
}
Questions about a grading program?
Page 1 of 13 Replies - 242 Views - Last Post: 05 October 2012 - 05:21 PM
#1
Questions about a grading program?
Posted 05 October 2012 - 05:03 PM
HI I'm having some trouble understanding how I would go about making a program that asks for 2 quiz grades, a midterm grade, and a final grade and then it takes them, weights them (as quizzes = 25%, midterm = 25%, and final = 50%) and then gives an overall grade. I have the code below, but I'm lost as to where I should go from here, plus when I try to run it, it terminates automatically. Any input is greatly appreciated!
Replies To: Questions about a grading program?
#2
Re: Questions about a grading program?
Posted 05 October 2012 - 05:06 PM
You don't have a main() method, which is required to run your program.
#3
Re: Questions about a grading program?
Posted 05 October 2012 - 05:13 PM
#4
Re: Questions about a grading program?
Posted 05 October 2012 - 05:21 PM
I just glanced through your code, but it looks good so far for what you're doing.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote







|