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...
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...
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...
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 does the following: a) The user will enter data such as...
Write a java program that does the following: a) The user will enter data such as client name and client balance. The user can stop inputting data by entering "stop". The program should store the user inputs as a data member of an array. The type of this array is a class named ClientData. Below the output should be displayed by the program. The parts in bold are inputs from the user and not hard coded in the program Client...
Using Java, design a program to let user enter two lists of numbers within the range...
Using Java, design a program to let user enter two lists of numbers within the range [0, 9] from keyboard, you could either use flag to denote end of the list or ask user to enter the list size first and then enter the list numbers. Each of these two lists represents a set (keep in mind that duplicate elements are not allowed in the same set but are allowed between sets), so we have two sets A and B....
Create a program in java with the following information: Design a program that uses an array...
Create a program in java with the following information: Design a program that uses an array with specified values to display the following: The lowest number in the array The highest number in the array The total of the numbers in the array The average of the numbers in the array Initialize an array with these specific 20 numbers: 26 45 56 12 78 74 39 22 5 90 87 32 28 11 93 62 79 53 22 51 example...
In java P4.6 Following Section 4.9 develop a program that reads text and displays the average...
In java P4.6 Following Section 4.9 develop a program that reads text and displays the average number of words in each sentence. Assume words are separated by spaces, and a sentence ends when a word ends in a period. Start small and just print the first word. Then print the first two words. Then print all words in the first sentence. Then print the number of words in the first sentence. Then print the number of words in the first...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT