Question

In: Computer Science

Design a program that displays the following in Java: Enter the grades for an Essay: Grammer...

Design a program that displays the following in Java:

Enter the grades for an Essay:

Grammer (must be 30 or less):

40

Grammer (must be 30 or less):
26.3
Spelling (must be 20 or less):
17.4
Correct Length (must be 20 or less):
19
Content (must be 30 or less):
23.5

The recorded scores are:
Grammer: 26.3
Spelling: 17.4
Correct Length: 19.0
Content: 23.5
Total score: 86.2

The grade for this essay is B

Solutions

Expert Solution

import java.util.*;

public class Main
{
//function to calculate grade
public static char grade(double score)
{
if(score>=90)
return 'A';
else if(score>=80)
return 'B';
else if(score>=70)
return 'C';
else if(score>=60)
return 'D';
else
return 'F';
}

   public static void main(String[] args)
   {
   Scanner sc = new Scanner(System.in);
  
   //get user input
   System.out.println("Enter the grades for an Essay: ");
       double grammerScore, spellingScore, lengthScore, contentScore, totalScore;
      
       while(true)
       {
       System.out.println("Grammer (must be 30 or less): ");
       grammerScore = sc.nextFloat();
       if(grammerScore<=30)
       break;
       }
      
       while(true)
       {
       System.out.println("Spelling (must be 20 or less):");
       spellingScore = sc.nextFloat();
       if(spellingScore<=20)
       break;
       }
      
       while(true)
       {
       System.out.println("Correct Length (must be 20 or less):");
       lengthScore = sc.nextFloat();
       if(lengthScore<=20)
       break;
       }
      
       while(true)
       {
       System.out.println("Content (must be 30 or less):");
       contentScore = sc.nextFloat();
       if(contentScore<=30)
       break;
       }
      
       //calculate the total score
       totalScore = grammerScore+spellingScore+lengthScore+contentScore;
      
       //display the output
       System.out.println("\nThe recorded scores are:");
       System.out.printf("Grammer: %.1f\n",grammerScore);
       System.out.printf("Spelling: %.1f\n", spellingScore);
       System.out.printf("Correct Length: %.1f\n", lengthScore);
       System.out.printf("Content: %.1f\n", contentScore);
       System.out.printf("Total score: %.1f\n", grammerScore);
      
       //display the grade
       System.out.println("\nThe grade for this essay is "+grade(totalScore));
   }
}

OUTPUT:

Enter the grades for an Essay:
Grammer (must be 30 or less):
40
Grammer (must be 30 or less):
26.3
Spelling (must be 20 or less):
17.4
Correct Length (must be 20 or less):
19
Content (must be 30 or less):
23.5

The recorded scores are:
Grammer: 26.3
Spelling: 17.4
Correct Length: 19.0
Content: 23.5
Total score: 26.3

The grade for this essay is B



Related Solutions

Design the logic for a program that allows a user to enter 20 numbers, then displays...
Design the logic for a program that allows a user to enter 20 numbers, then displays them in the reverse order of entry. Design the logic for a program that allows a user to enter 20 numbers, then displays each number and its difference from the numeric average of the numbers entered. The program is C++. I need a Pseudocode
Design a program in Java to display the following: Car Design Enter the car model's year:...
Design a program in Java to display the following: Car Design Enter the car model's year: 1957 Enter the car's make: Chevy The model year is 1957 The make is Chevy The speed is 0 Let's see what it can do!! The speed is,... 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 STOP! STOP! Let me OUT! The...
Design a program in Java to display the following: Car Design Enter the car model's year:...
Design a program in Java to display the following: Car Design Enter the car model's year: 1957 Enter the car's make: Chevy The model year is 1957 The make is Chevy The speed is 0 Let's see what it can do!! The speed is,... 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 STOP! STOP! Let me OUT! The...
JAVA Write a test program that prompts the user to enter a list and displays whether...
JAVA Write a test program that prompts the user to enter a list and displays whether the list is sorted or not. Here is a sample run. Note that the program first prompts the user to enter the size of the list. Using Array My output should look like this Enter the size of the list: 8 Enter the contents of the list: 10 1 5 16 61 9 11 1 The list has 8 integers 10 1 5 16...
Create a program in JAVA that displays a design or picture for someone in your quarantine...
Create a program in JAVA that displays a design or picture for someone in your quarantine household/group: a pet, a parent, a sibling, a friend. Make them a picture using the tools in TurtleGraphics and run your program to share it with them! Use a pen object, as well as any of the shape class objects to help you create your design. You must use and draw at least 5 shape objects. - You must use a minimum of 4...
Objective: CODE IN JAVA Create a program that displays a design or picture for someone in...
Objective: CODE IN JAVA Create a program that displays a design or picture for someone in your quarantine household/group: a pet, a parent, a sibling, a friend. Make them a picture using the tools in TurtleGraphics and run your program to share it with them! Use a pen object, as well as any of the shape class objects to help you create your design. You must use and draw at least 5 shape objects. You must use a minimum of...
Develop a rudimentary Java program that will allow anyone to enter any number of grades and...
Develop a rudimentary Java program that will allow anyone to enter any number of grades and then calculate grade point average. For reference, a grade point average is a weighted average of a set of grades based on the relative number of credits. For example, a 1 credit “A” (4.0) should count twice as much as a .5 credit “C” (3.0), and a 1.5 credit “A+”(4.33) should count three times as much as the “C” and 1.5 times as much...
Java Programming Write a program that displays the following pattern *                         *       &nbsp
Java Programming Write a program that displays the following pattern *                         *          *          * *          *          *          *          *          *          *          *          *          *          *          *             *          *          *          *          *                         *          *          *                                     * Printing Pattern A * ** *** **** ***** ****** ******* Printing Pattern B ******* ****** ***** **** *** ** * Printing Pattern C * ** *** **** ***** ****** *******
Design, plan, test, and write a computer program in Java that asks the user to enter...
Design, plan, test, and write a computer program in Java that asks the user to enter 1 number and a String. You will display the first n characters of the string where n is the number entered. For example, if the user enters 3 and java then you will print jav. If they enter 5 and Halloween then you print Hallo. If the user enters a number less than 0 then set the number to 0. Assume the user will...
Write a Java program that reads a name and displays on the screen.
Write a Java program that reads a name and displays on the screen.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT