Overclock.net banner

Need Java Assignment help Asap

392 views 1 reply 2 participants last post by  XAslanX 
#1 ·
Your mission should you choose to accept it.

Write a Java program that allows the teacher to calculate the grade for a student. The teacher will first enter the
Student ID number, first name, and last name. This will be followed by entering in the score for each of the following
categories: Assignments, Quizzes, Midterm Exam, & Final Exam
The weights for each category are as follows:
Assignments - 50%
Quizzes - 20%
Midterm - 10%
Final - 20%

Once you have the scores for each individual category, calculate a total score for the course. Then assign a letter grade
to the student based on the following grade scale:
90 - 100 = A
80 - 90 = B
70 - 80 = C
60 - 70 = D
< 60 = E

Print the results in exactly the following format:
[Last Name], [First Name]
Student ID: [Student ID]
Homework: [Homework Score]
Quizzes: [Quizzes Score]
Midterm: [Midterm Score]
Final: [Final Score]
Total Score: [Total Score] Grade: [Letter Grade]

Then ask the user if they would like to enter another student or quit. Continue the process until the user chooses to
quit.

This is what I have so far

import java.util.*;

public class StudentGrades {

public static void main (String[] args) {

Scanner console = new Scanner (System.in);

String sSID = "";
String sInputF = "";
String sInputL = "";
String sGrade = "";
double dWeightAssign = 50;
double dWeightQuiz = 20;
double dWeightMidE = 10;
double dWeightFinalE = 20;
double dStudentAssign = 0;
double dStudentQuiz = 0;
double dStudentMidE = 0;
double dStudentFinalE = 0;
double dTotalAssign = 0;
double dTotalQuiz = 0;
double dTotalMidE = 0;
double dTotalFinalE = 0;
double dTotalScore = 0;

//Preform calculation
dTotalAssign = dWeightAssign * dStudentAssign;
dTotalQuiz = dWeightQuiz * dStudentQuiz;
dTotalMidE = dWeightMidE * dStudentMidE;
dTotalFinalE = dWeightFinalE * dStudentFinalE;
dTotalScore = (dWeightAssign * dStudentAssign) + (dWeightQuiz * dStudentQuiz) +
(dWeightMidE * dStudentMidE) + (dWeightFinalE * dStudentFinalE);

//Get user input
System.out.println("Please enter student's ID Number.");
sSID = console.nextLine();

System.out.println("Please enter student's First Name.");
sInputF = console.nextLine();

System.out.println("Please enter student's Last Name.");
sInputL = console.nextLine();

System.out.println("Please enter student's score for Assignments");
dStudentAssign = console.nextDouble ();

System.out.println("Please enter student's score for Quizes");
dStudentQuiz = console.nextDouble ();

System.out.println("Please enter student's score for Midterm Exam");
dStudentMidE = console.nextDouble ();

System.out.println("Please enter student's score for Final Exam");
dStudentFinalE = console.nextDouble ();

if (dTotalScore >= 90) {
sGrade = "A";
}
else if (dTotalScore >= 80) {
sGrade = "B";
}
else if (dTotalScore >= 70) {
sGrade = "C";
}
else if (dTotalScore >= 60) {
sGrade = "D";
}
else {
sGrade = "F";
}
System.out.println(sGrade);

I have also tried the following for the letter grade

if (dTotalScore >= 90) {
System.out.println("A");
}

else if (dTotalScore >= 80)
{
System.out.println("B");
}

else if (dTotalScore >= 70)
{
System.out.println("C");
}

else if (dTotalScore >= 60)
{
System.out.println("D");
}

else
{
System.out.println("F");
}

Neither way has worked

}

}
 
See less See more
#2 ·
Try this:

Code:

Code:
/**
 * The mark calculation class.
 * @author Numbers
 * /

import java.io.*;

public class MarkCalc {

    static String studentId;
    static String firstName;
    static String lastName;
    static double assignments;
    static double quizzes;
    static double midterm;
    static double finals;
    static int repeat = 1;

    static double finalPercent;

    private static double weightedAve(int weight, double mark) {
        return (weight * mark / 100);
    }

    private static String finalGrade(double assignments, double quizzes, double midterm, double finals) {

        if (finalPercent >= 90) {
            return "A";
        } else if (finalPercent >= 80 && finalPercent <= 89) {
            return "B";
        } else if (finalPercent >= 70 && finalPercent <= 79) {
            return "C";
        } else if (finalPercent >= 60 && finalPercent <= 69) {
            return "D";
        } else {
            return "E";
        }
    }

    private static boolean newStudent(int repeat) {
        return (repeat == 1);
    }

    public static void main(String[] args) throws IOException {

        BufferedReader input = new BufferedReader (new InputStreamReader(System.in)); // Initializes the reader to allow for user input.

        while (newStudent (repeat))
        {

            System.out.print("Please enter the student number: ");
            studentId = input.readLine ();
            System.out.println();

            System.out.print("Please enter the student's last name: ");
            lastName = input.readLine ();
            System.out.println();

            System.out.print("Please enter the student's first name: ");
            firstName = input.readLine ();
            System.out.println();

            System.out.print("Please enter the overall mark for assignments: ");
            assignments = Double.parseDouble (input.readLine ());
            System.out.println();

            System.out.print("Please enter the overall mark for quizzes: ");
            quizzes = Double.parseDouble (input.readLine ());
            System.out.println();

            System.out.print("Please enter the overall mark for midterm: ");
            midterm = Double.parseDouble (input.readLine ());
            System.out.println();

            System.out.print("Please enter the overall mark for finals: ");
            finals = Double.parseDouble (input.readLine ());
            System.out.println();

            assignments = weightedAve(50, assignments);
            quizzes = weightedAve(20, quizzes);
            midterm = weightedAve(10, midterm);
            finals = weightedAve(20, finals);
            finalPercent = (assignments + quizzes + midterm + finals);

            System.out.println(lastName + ", " + firstName);
            System.out.println("Student ID: " + studentId);
            System.out.println("Homework: " + assignments);
            System.out.println("Quizzes: " + quizzes);
            System.out.println("Midterm: " + midterm);
            System.out.println("Final: " + finals);
            System.out.println("Total Score: " + finalPercent + "% Grade: " + finalGrade (assignments, quizzes, midterm, finals));
            System.out.println();
            System.out.print("Enter 1 for new student. Enter any other value to exit: ");
            repeat = Integer.parseInt(input.readLine ());
            System.out.println();
            newStudent (repeat);
        }
    } // main method

}
 
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top