Need Java Assignment help Asap - Overclock.net - An Overclocking Community

Forum Jump: 

Need Java Assignment help Asap

 
Thread Tools
post #1 of 2 (permalink) Old 11-30-2016, 05:56 PM - Thread Starter
New to Overclock.net
 
Zalas's Avatar
 
Join Date: Nov 2016
Posts: 1
Rep: 0
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


}


}
Zalas is offline  
Sponsored Links
Advertisement
 
post #2 of 2 (permalink) Old 12-01-2016, 09:51 PM
Retired Staff
 
XAslanX's Avatar
 
Join Date: Aug 2007
Location: Georgia
Posts: 5,639
Rep: 292 (Unique: 219)
Try this:
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

}

I don't reply to trolls.

RIP SyrillianWarning: Spoiler! (Click to show)
Quote:
Originally Posted by Syrillian go_quote.gif

Woohoo!


Well done you zombie stompin', Best Buy dissin' Lion Man!

applaud.gif


XAslanX is offline  
Reply

Quick Reply
Message:
Options

Register Now

In order to be able to post messages on the Overclock.net - An Overclocking Community forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.
User Name:
If you do not want to register, fill this field only and the name will be used as user name for your post.
Password
Please enter a password for your user account. Note that passwords are case-sensitive.
Password:
Confirm Password:
Email Address
Please enter a valid email address for yourself.
Email Address:

Log-in



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off