0% found this document useful (0 votes)
160 views1 page

Grade Calculator

This document contains the source code for a Java class called GradeCalculator. The class contains a main method that calculates a student's final grade based on their scores in homeworks, exams, and projects. It prompts the user to input the student's scores for each category, calculates the percentage of the final grade for each, and outputs the student's total grade and a remark of whether they passed or failed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
160 views1 page

Grade Calculator

This document contains the source code for a Java class called GradeCalculator. The class contains a main method that calculates a student's final grade based on their scores in homeworks, exams, and projects. It prompts the user to input the student's scores for each category, calculates the percentage of the final grade for each, and outputs the student's total grade and a remark of whether they passed or failed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

C:/Users/John Gomez/Documents/NB2024/SecondWeek/src/GradeCalculator.

java
1
2
3 import java.util.Scanner;
4
5
6 /**
7
8 * GradeCalculator "description"
"description
9
10
* @author John Leonard Gomez
11 * @since Jan 24, 2024
12
13 * @instructor John Gomez
14
*/
15
16 public class GradeCalculator
17
18
19 {
20
21 public static void main(String
(String args[])
22
{
23
24 final double HW = 0.20;
25
26
final double EXAMS = 0.50;
27 final double PROJ = 0.30;
28
29
30
Scanner userInput = new Scanner(System.in);
Scanner(System.

//welcome to grade calculator simulation


System.out.println("Student
System. .println("Student Grade Calculator"
+ "\n==========================================================="
" ==========================================================="
+ "\nHomeworks:
" Homeworks: 20% of the grade (Total Score is 30)"
+ "\nExams:
" Exams: 50% of the grade (Total Score is 100)"
+ "\nProjects:
" Projects: 30% of the grade (Total Score is 60)"
+ "\n==========================================================="
" ==========================================================="
);
System.out.println("Student
System. .println("Student Name: MIA COOK");
System.out.println("Enter
System. .println("Enter student's \"Total Homework\" score: ");

//if-elseif-else statement for INPUT validation


//if(hwScore < 0), enter a valid score
//elseif(hwScore >30), enter a valid score, out of bounds.
//else perform the calculations and necessary outputs
//In your practice, add the comments for each of the components
//As well as to capture (validate) the score inputs according to the perfect score.

double hwScore = userInput.nextInt();


double hwComp = Math.round((((hwScore
Math. ((((hwScore / 30)*100.0)*HW)*100)/100.0;
System.out.println(hwComp
System. .println(hwComp + "% of the final grade.");
System.out.println("-----------------------------------------------------");
System. .println("-----------------------------------------------------");

System.out.println("Enter
System. .println("Enter student's \"Total Exams\" score: ");
double eScore = userInput.nextInt();
double eComp = Math.round((((eScore
Math. ((((eScore / 100)*100.0)*EXAMS)*100)/100.0;
System.out.println(eComp
System. .println(eComp + "% of the final grade.");
System.out.println("-----------------------------------------------------");
System. .println("-----------------------------------------------------");

System.out.println("Enter
System. .println("Enter student's \"Total Projects\" score: ");
double pScore = userInput.nextInt();
double pComp = Math.round((((pScore
Math. ((((pScore / 60)*100.0)*PROJ)*100)/100.0;
System.out.println(pComp
System. .println(pComp + "% of the final grade.");

System.out.println("-----------------------------------------------------");
System. .println("-----------------------------------------------------");
System.out.println("-----------------------------------------------------");
System. .println("-----------------------------------------------------");
double total = hwComp+eComp+pComp;
System.out.println("MIA
System. .println("MIA COOK'S Grade is " + total +"%.");

if(total >= 75.0)


{
System.out.println("Rem
System. .println("Rem arks: PASSED");
}
else
{
System.out.println("Remarks:
System. .println("Remarks: FAILED");
}

1.1 of 1 2024.01.26 10:24:48

You might also like