Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the program below so that it prompts for and reads in a student\'s fina

ID: 3754006 • Letter: C

Question

Complete the program below so that it prompts for and reads in a student's final class average (0.0 to 100.0), and prints out the letter grade the student should receive, based on the following table:

A : greater than 90.0, up to 100.0

B : greater than 80.0, up to 90.0

C : greater than 70.0, up to 80.0

D : greater than 60.0, up to 70.0

F : 0.0 up to 60.0

For example, if a student's final class average is 84.6, he has earned a letter grade of B.

Complete the following file:

import java.util.Scanner;

/**
This program reads a student's final class average,
and prints out the appropriate letter grade.
*/
public class DoGrades
{
public static void main(String[] args)
{
// Print prompt to enter a final class average
System.out.print("Enter final class average: ");

// Read in final class average
Scanner in = new Scanner(System.in);
double average = in.nextDouble();

String finalGrade;

// Determine and print final grade

// Your work here

System.out.println(finalGrade);
}
}

Explanation / Answer

Code:

import java.util.Scanner;
public class DoGrades {
public static void main(String args[]) {
// Print prompt to enter a final class average
System.out.print("Enter final class average: ");
  
// Read in final class average
Scanner in = new Scanner(System.in);
double average = in.nextDouble();
//Initialize before using it
String finalGrade=null;
  
// Determine and print final grade
//If average is between 90 to 100 Grade is A
if(average>90&&average<=100)
finalGrade="A";
//If average is between 80 to 90 Grade is B
else if(average>80&&average<=90)
finalGrade="B";
//If average is between 70 to 80 Grade is C
else if(average>70&&average<=80)
finalGrade="C";
//If average is between 60 to 70 Grade is D
else if(average>60&&average<=70)
finalGrade="D";
//If average is between 0 to 60 Grade is F
else if(average>=0&&average<=60)
finalGrade="F";
// Your work here
if(finalGrade!=null)
System.out.println(finalGrade);
else
System.out.println("Invalid Marks Please Enter Correct Marks");

}
}

Output:

84.6
Enter final class average: B

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote