1) Write a static method called Scores that prompts the user for two students\'
ID: 3550098 • Letter: 1
Question
1) Write a static method called Scores that prompts the user for two students' overall scores and that computes their letter grades based on those scores. Assume that scores are in the range of 0 to 100 and that grades are based on the following scale:
Score Grade
-------------------------
< 60 0.0
60-62 0.7
63 0.8
64 0.9
65 1.0
...
93 3.8
94 3.9
>= 95 4.0
You should also report whether or not the students passed the course (i.e., whether or not the user got a grade above 0.0) and whether the student may advance to the next course (i.e., whether or not the user got a grade of 2.0 or higher). If the student's grade percent has a decimal, round it to the nearest whole number.
Here is a sample log of execution of the program (user input underlined):
This program converts two scores into grades.
Student 1:
What score did you get? 83.7
You received a grade of 2.8
You passed the course
You may advance to the next course
Student 2:
What score did you get? 59.1
You received a grade of 0.0
You failed the course
You must take the course again
Use static methods to capture the structure and redundancy of the program. Your should have at least two static methods to implement this problem.
Explanation / Answer
public static void Scores()
{
Scanner input = new Scanner(System.in);
System.out.println("What score did you get?");
double score = input.nextDouble();
checkGrade(score);
}
}
public static void checkGrade(Double score)
{
double grade = 0;
if (score < 60)
grade = 0;
else if (score >= 60 && score <= 62)
grade = 0.7
else if (score < 96)
grade = 0.8 + (score - 63)/10;
else
grade = 4;
printScore(grade);
}
public static void printScore(Double grade)
{
System.out.println("You received a grade of "+ grade);
if (grade > 0)
{
System.out.println("You passed the course");
System.out.println("You may advance to the next course");
}
else
{
System.out.println("You failed the course");
System.out.println("You must take the course again");
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.