i have a question on how i could calculate the overall score of the users input using five instance variables, three for three quizzes, one for a midterm and one for a final exam. the quizzes are graded between 1 and 10 while the midterm and final are graded between 1 and 100. the quizzes count for 25 percent of the grade, the midterm 35 percent, and the final 40 percent

i got everything else to work on my program, i just need help calculating the overall grade and i also need it to go into my toString method so when i call the toString method in my driver program, it will output the three quiz grades, the midterm the final ,and the overall grade which needs to be calculated and not inputed like the others.

i appreciate any help thank you very much

public class over
{
    private double quizOne;//instance variables
    private double quizTwo;
    private double quizThree;
    private double midterm;
    private double finals;
    private double overall;
    private char letter;

    public Grade()//constructors
    {
        quizOne = 6.0;
        quizTwo = 7.0;
        quizThree = 8.0;
        midterm = 82.0;
        finals = 78.0;
        overall = 75.0;
        letter = 'C';
    }

    public Grade(double q, double r, double s, double m, double f, double o, char l)
    {
        quizOne = q;
        quizTwo = r;
        quizThree = s;
        midterm = m;
        finals = f;
        overall = o;
        letter = l;
    }

    public double getQuizOne()//accessor methods
    {
        return quizOne;
    }

    public double getQuizTwo()
    {
        return quizTwo;
    }

    public double getQuizThree()
    {
        return quizThree;
    }

    public double getMidterm()
    {
        return midterm;
    }

    public double getFinals()
    {
        return finals;
    }

    public double getOverall()
    {
        return overall;
    }

    public char getLetter()
    {
        return letter;
    }

    public void setQuizOne(double qo)//mutator methods
    {
        if(checkQuiz(qo))
            quizOne = qo;
        else 
            System.out.println("Fatal Error.");
    }

    public void setQuizTwo(double qtw)
    {
        if(checkQuiz(qtw))
            quizTwo = qtw;
        else 
            System.out.println("Fatal Error.");
    }

    public void setQuizThree(double qth)
    {
        if(checkQuiz(qth))
            quizThree = qth;
        else
            System.out.println("Fatal Error.");
    }

    public void setMidterm(double m)
    {
        if(checkMajor(m))
            midterm = m;
        else 
            System.out.println("Fatal Error.");
    }

    public void setFinals(double f)
    {
        if(checkMajor(f))
            finals = f;
        else
            System.out.println("Fatal Error.");
    }

    public double calculateFinalScore(double quizOne, double quizTwo, double quizThree, double midterm, double finals)
    {
        overall = ((.25*((quizOne+quizTwo+quizThree)/3))+(.35*midterm)+(.40*finals));
        return overall;
    }

    public char calculateLetter()
    {
        if(overall<60.0)
            letter = 'F';
        else if(overall<70.0)
            letter = 'D';
        else if(overall<80.0)
            letter = 'C';
        else if(overall<90.0)
            letter = 'B';
        else if(overall<100.0)
            letter = 'A';
        else
            System.out.println("Fatal Error.");
            return 0;//needed to keep compiler happy
    }

    public boolean checkQuiz(double q)//facilitator methods
    {
        if(q>=0.0 && q<=10.0)
            return true;
        else
            return false;
    }

    public boolean checkMajor(double cm)
    {
        if(cm>=0.0 && cm<=100.0)
            return true;
        else
            return false;
    }

    public boolean equals(Grade myGrade)//equals method
    {
        if((this.quizOne==myGrade.quizOne)&&(this.quizTwo==myGrade.quizTwo)&&(this.quizThree==myGrade.quizThree)&&(this.midterm==myGrade.midterm)&&(this.finals==myGrade.finals))
            return true;
        else
            return false;
    }

    public String toString()//toString method
    {
        return("The grade for quiz 1 is: " + quizOne + " The grade for quiz 2 is: " + quizTwo + " The grade for quiz is: " + quizThree + " The grade for the midterm is: " + midterm + " The grade for the final exam is: " + finals + " The overall grade is: " + overall + " which is a " + letter);
    }
}

import java.util.Scanner;

public class driver2
{
    public static void main(String[] args)
    {
        Grade good = new Grade();
        Scanner keyboard = new Scanner(System.in);
        int p = 0;
        while(p!=-1)
        {
            System.out.println("Enter the grade for quiz 1 from 0 to 10 points as a decimal.");
            good.setQuizOne(keyboard.nextDouble());
            System.out.println("Enter the grade for quiz 2 from 0 to 10 points as a decimal.");
            good.setQuizTwo(keyboard.nextDouble());
            System.out.println("Enter the grade for quiz 3 from 0 to 10 points as a decimal.");
            good.setQuizThree(keyboard.nextDouble());
            System.out.println("Enter the grade for the midterm exam from 0 to 100 points as a decimal.");
            good.setMidterm(keyboard.nextDouble());
            System.out.println("Enter the grade for the midterm exam from 0 to 100 points as a decimal.");
            good.setFinals(keyboard.nextDouble());
            System.out.println("Your overall grade is: ");
            System.out.println(good.calculateFinalScore());
            System.out.println(good);
            System.out.println("Enter a 1 to use the grade program or a -1 to quit.");
            p = keyboard.nextInt();
        }
    }
}

im having trouble with the calculatingFinalScore and outputting the letter and overall score
thank you for your help

Edited 3 Years Ago by Reverend Jim: Fixed formatting

i know how to output the overall score now, i just need to know how to output the letter grade

forget it i found it out thanks for nothing

With posts like this, "nothing" is pretty much what you are likely to get in the future as well.

This question has already been answered. Start a new discussion instead.