DESIGN and COMPLTE a program ACCORDINGLY that determines fin

DESIGN and COMPLTE a program ACCORDINGLY that determines final letter grade for a student with encouraging comment. Three exams and two assignment scores as well as the student name will be entered by the user. Every score should range from 0.00 – 100.00. The program will give user only one chance to correct invalid score and provide meaningful feedback. Exams and assignments have equal weights for the final score (i.e. 50% by each category) that determines the final grade. Final grade and comment are determined by the following scale: A – 90 or above (Excellent!!) B – between 80.00 – 89.99 (Good job!) C – between 70.00 – 79.99 (Happy? Not happy?) D – between 60.00 – 69.99 (Could be better, right?) F – below 60.00 (Could be improved next time?)

Solution

Please follow the code and comments for description :

CODE :

import java.util.Scanner;

public class StudentGrades {

    static int count = 0; // count to get the number of changes in the score that are made

    public static void main(String[] args) { // main driver method
        count++; // incrementing the count
        if (count <= 2) { // providing only a single chance to the user to change the data
            Scanner sc = new Scanner(System.in); // scanner class to get the data
            System.out.println(\"Please Enter the Student\'s Name : \"); // promot to enter the data for the user
            String name = sc.nextLine(); // getting the name

            System.out.println(\"Please Enter the Two Assignment\'s Scores (0 - 100) : \"); // prompt to enter the assignments marks
            System.out.println(\"Enter the First Assignment Score : \");
            double ass1 = sc.nextDouble(); // getting the data
            System.out.println(\"Enter the Second Assignment Score : \");
            double ass2 = sc.nextDouble();
            if ((ass1 < 0 || ass1 > 100) || (ass2 < 0 || ass2 > 100)) { // checking the data of scores entered
                System.out.println(\"Invalid Scores of Assignments!\");
                main(null); // if incorrect returning to the main again
            }
            double assTotal = ass1 + ass2; // calculating the total marks
            double assAvg = (assTotal * 50) / 200;
            System.out.println(\"Total Score in the Assignments : \" + assAvg); // getting the total of assignments

            System.out.println(\"Please Enter the Three Exam\'s Scores (0 - 100) : \"); // propmt to enter the exam marks
            System.out.println(\"Enter the First Exam Score : \");
            double ex1 = sc.nextDouble(); // getting the data
            System.out.println(\"Enter the Second Exam Score : \");
            double ex2 = sc.nextDouble();
            System.out.println(\"Enter the Third Exam Score : \");
            double ex3 = sc.nextDouble();
            if ((ex1 < 0 || ex1 > 100) || (ex2 < 0 || ex2 > 100) || (ex3 < 0 || ex3 > 100)) {// checking the data entered
                System.out.println(\"Invalid Scores of Exams!\");
                main(null); // returning to the main again if invalid data
            }
            double exTotal = ex1 + ex2 + ex3;
            double exAvg = (exTotal * 50) / 300; // calculating the total exam scores
            System.out.println(\"Total Score in the Exams : : \" + exAvg); // printing the data

            double FinalScore = assAvg + exAvg; // calculating the final score
            System.out.println(\"The Final Score Obtaineed is : \" + FinalScore); // printing the final data
            System.out.println(\"Hi \" + name);

            if (FinalScore >= 90) { // checking to get the grades
                System.out.println(\"Your Grade is A.\");
                System.out.println(\"Excellent!!\");
            } else if (FinalScore >= 80.00 && FinalScore <= 89.99) {
                System.out.println(\"Your Grade is B.\");
                System.out.println(\"Good job!\");
            } else if (FinalScore >= 70.00 && FinalScore <= 79.99) {
                System.out.println(\"Your Grade is C.\");
                System.out.println(\"Happy? Not happy?\");
            } else if (FinalScore >= 60.00 && FinalScore <= 69.99) {
                System.out.println(\"Your Grade is D.\");
                System.out.println(\"Could be better, right?\");
            } else if (FinalScore < 60.00) {
                System.out.println(\"Your Grade is F.\");
                System.out.println(\"Could be improved next time?\");
            }

        } else {
            System.out.println(\"Exiting the Code!\"); // exiting the code if any invalid data
            System.exit(0);
        }
    }
}

OUTPUT :

Please Enter the Student\'s Name :
John Carter
Please Enter the Two Assignment\'s Scores (0 - 100) :
Enter the First Assignment Score :
50
Enter the Second Assignment Score :
102
Invalid Scores of Assignments!
Please Enter the Student\'s Name :
Mark
Please Enter the Two Assignment\'s Scores (0 - 100) :
Enter the First Assignment Score :
56
Enter the Second Assignment Score :
98
Total Score in the Assignments : 38.5
Please Enter the Three Exam\'s Scores (0 - 100) :
Enter the First Exam Score :
86
Enter the Second Exam Score :
91
Enter the Third Exam Score :
65
Total Score in the Exams : : 40.333333333333336
The Final Score Obtaineed is : 78.83333333333334
Hi Mark
Your Grade is C.
Happy? Not happy?


Hope this is helpful.

DESIGN and COMPLTE a program ACCORDINGLY that determines final letter grade for a student with encouraging comment. Three exams and two assignment scores as wel
DESIGN and COMPLTE a program ACCORDINGLY that determines final letter grade for a student with encouraging comment. Three exams and two assignment scores as wel

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site