Question

In: Computer Science

Java programming Question1 You will create a full program called LetterGrade that will have the user...

Java programming

Question1 You will create a full program called LetterGrade that will have the user enter in 2 test scores as double values. It will compute the average and then using else..if statements it will display the letter grade based on my grading scale listed in the course outline.

Solutions

Expert Solution

This problem statement inputs two test scores and calculate the average of those score. Then based on average, it displays the grade using else.. if . Since grading scale is not given in the question, So I have assumed some grading scales i.e. scores above 80 - Grade A, scores between 60 and 80 - Grade B, scores below 60 - Grade C. I have assumed these grades. You may change these grades as per grading scale listed in your course outline.

//Code starts here

/******************************************************************************

Java programming
Question1 You will create a full program called LetterGrade that will have the user enter in 2 test scores
as double values. It will compute the average and then using else..if statements it will display the
letter grade based on my grading scale listed in the course outline.

*******************************************************************************/
import java.util.Scanner;
public class LetterGrade
{
   public static void main(String[] args) {
   //variables to store two test scores and average
       double firstTest,secondTest,average;
       //Class to get user input
       Scanner in = new Scanner(System.in);
       //variable to store grade
       char grade;
       //Enter first test score
       System.out.println("Enter first test score");
       firstTest = in.nextDouble();
       //Enter second test score
       System.out.println("Enter second test score");
       secondTest = in.nextDouble();
       //Calculate average of two scores
       average = (firstTest + secondTest)/2;
       // Since the grade scale is not given in question, I have assumed that the grade above 80 score is A.
       //The grade between 60 and 80 is B.
       //The grade below 60 is C.
       System.out.println("The average of two scores: "+average); //Display average of two scores
       //the grade above 80 score is A
       if(average >= 80){
       grade = 'A';
       }
       //The grade between 60 and 80 is B.
       else if(average >= 60 && average <80){
       grade = 'B';
       }
       //The grade below 60 is C.
       else{
       grade = 'C';
       }
       //Display grade
       System.out.println("The grade is : "+grade);
   }
}

//Code ends here

Output


Related Solutions

Java Programming Create a program that prompts the user for an integer number and searches for...
Java Programming Create a program that prompts the user for an integer number and searches for it within an array of 10 elements. What is the average number of comparisons required to find an element in the array? Your program should print the number of comparisons required to find the number or determine that the number does not exist. Try finding the first and last numbers stored in the array. Run your program several times before computing the average.
Create a java program that will do the following: Create a method called getInt.Allow the user...
Create a java program that will do the following: Create a method called getInt.Allow the user to enter up to 20 student names,and for each student 3 quiz scores (in the range 0-100). Once input is done, display each student’s name, their three quiz scores, and their quiz score average, one student per line. The output table does not need to line up perfectly in columns.Use dialog boxes for all input and output.Use the method to input the three scores.Parameter...
IN JAVA PROGRAMMING Write a complete Java program to do the following: a) Prompt the user...
IN JAVA PROGRAMMING Write a complete Java program to do the following: a) Prompt the user to enter the name of the month he/she was born in (example: September). b) Prompt the user to enter his/her weight in pounds (example: 145.75). c) Prompt the user to enter his/her height in feet (example: 6.5). d) Display (print) a line of message on the screen that reads as follows: You were born in the month of September and weigh 145.75 lbs. and...
IN JAVA PROGRAMMING Write a complete Java program to do the following: a) Prompt the user...
IN JAVA PROGRAMMING Write a complete Java program to do the following: a) Prompt the user to enter a six-digit integer. b) Take the integer and break it up into two pieces of three-digits each (make sure you keep the order of digits). c) Display each 3-digit piece on a separate line with a proper message before each piece. For example, if the user enters  450835 as the integer, then the program should display the following output: Right 3-digit piece: 835...
Write by hand a full java program that will prompt the user for the length and...
Write by hand a full java program that will prompt the user for the length and width of a square, calculate and display the area of that square rounded to the nearest tenth with an appropriate message.
1.Create full program in Java that will simulate a Rock Paper Scissors Game You will create...
1.Create full program in Java that will simulate a Rock Paper Scissors Game You will create the code so that when the program is run the user will see in the console the following: We are going to play rock paper scissors. Please choose 1 for Rock 2 for Paper or 3 for scissors. The program will have your choice which is the integer-valued typed in by the user and compChoice which will be the randomly generated value of either...
C++ Question1. Create a class called Rantional for performing arithmatic with fractions. Then write a program...
C++ Question1. Create a class called Rantional for performing arithmatic with fractions. Then write a program to test your class. Use integer variables to represent the private data of the class, meaning the numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it's declared. The constructor should contain default values in case no initializers are provided and should store the fraction in reduced form. For example fraction 2/4 would be stored...
Create in Java a program that will prompt the user to enter aweight for a...
Create in Java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates both bolus and infusion rates based on weight of patient in an interactive GUI application, label it AMI Calculator. The patients weight will be the only entry from the user. Use 3999 as a standard for calculating BOLUS: To calculate the BOLUS you will multiply 60 times the weight of the patient for a total number. IF the...
Create in java a program that will prompt the user to enter a weight for a...
Create in java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates infusion rates based on weight of patient in an interactive GUI application, label it HEPCALC. The patients’ weight will be the only entry from the user. To calculate the infusion rate you will multiply 12 times the weight divided by 50 for a total number. The end result will need to round up or down the whole number....
THIS IS JAVA PROGRAMMING Guessing the Capitals. Write a program Lab5.java that repeatedly prompts the user...
THIS IS JAVA PROGRAMMING Guessing the Capitals. Write a program Lab5.java that repeatedly prompts the user to enter a capital for a state (by getting a state/capital pair via the StateCapitals class. Upon receiving the user’s input, the program reports whether the answer is correct. The program should randomly select 10 out of the 50 states. Modify your program so that it is guaranteed your program never asks the same state within one round of 10 guesses.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT