3 Replies - 532 Views - Last Post: 05 October 2012 - 05:21 PM Rate Topic: -----

#1 DeadTheory23  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 16-September 12

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! :bigsmile:
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 + " %.");
    }
    
}



Is This A Good Question/Topic? 0
  • +

Replies To: Questions about a grading program?

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10461
  • View blog
  • Posts: 38,753
  • Joined: 27-December 08

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.
Was This Post Helpful? 0
  • +
  • -

#3 DeadTheory23  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 16-September 12

Re: Questions about a grading program?

Posted 05 October 2012 - 05:13 PM

View Postmacosxnerd101, on 05 October 2012 - 05:06 PM, said:

You don't have a main() method, which is required to run your program.

Dang it I always forget that. Thanks. But besides that, is there anything else you can see?
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10461
  • View blog
  • Posts: 38,753
  • Joined: 27-December 08

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1