Question

In: Computer Science

write a Java program Write a program to assign a letter grade according to the following...

write a Java program

Write a program to assign a letter grade according to the following scheme:
A: total score >= 90
B: 80 <= total score < 90
C: 70 <= total score < 80
D: 60 <= total score < 70
F: total score < 60
Output - the student's total score (float, 2 decimals) and letter grade
Testing - test your program with the following input data:
test1 = 95; test2 = 80; final = 90; assignments = 80
The expected output is:  score = 86.25 and letter grade = B.

Solutions

Expert Solution


import java.util.Scanner;

public class TestPerson {
        public static void main(String[] args) {
                System.out.println("Enter scores: ");
                Scanner sc = new Scanner(System.in);
                double test1=sc.nextDouble();
                double test2=sc.nextDouble();
                double finalSc=sc.nextDouble();
                double assignment=sc.nextDouble();
                double total = (test1 + test2 + finalSc+assignment)/4;
                System.out.printf("score = %.2f\n",total);
                System.out.println("letter grade = "+getGrade(total));
                                
        }

        private static String getGrade(double n) {
                if(n>=90) return "A";
                if(n>=80) return "B";
                if(n>=70) return "C";
                if(n>=60) return "D";
                return "F";
        }
}

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.

I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME


Related Solutions

(c++ programming) We want to assign a letter grade based on the following scaling chart. Write...
(c++ programming) We want to assign a letter grade based on the following scaling chart. Write a program to do it Enter your score: 85 Your grade is a “B” 0-------------------60---------70-------------80-----------90-------------100 F D C B A MUST use nested if-else statements.
Write a program that uses a dictionary to assign “codes” to each letter of the alphabet....
Write a program that uses a dictionary to assign “codes” to each letter of the alphabet. For example:      codes = {'A':'%', 'a':'9', 'B':'@', 'b':'#', etc....} Using this example, the letter “A” would be assigned the symbol %, the letter “a” would be assigned the number 9, the letter “B” would be assigned the symbol “@” and so forth. The program should open a specified text file, read its contents, and then use the dictionary to write an encrypted version of...
Write a program in Java and run it in BlueJ according to the following specifications: The...
Write a program in Java and run it in BlueJ according to the following specifications: The program reads a text file with student records (first name, last name and grade on each line) and determines their type (excellent or ok). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "all" - prints all student records (first name, last name, grade, type). "excellent" - prints students with grade > 89. "ok"...
Write a c++ program that given a set of letter grade/credit hour combiniation, determines the grade...
Write a c++ program that given a set of letter grade/credit hour combiniation, determines the grade point average (GPA) Each A is worth 4 points. Each B is worth 3 points. Each C is worth 2 points. Each D is worth 1 point, and Each F is worth 0 points. The total quality points earned is the sum of the product of letter grade points and associated course credit hours. The GPA is the quotient of the quality points divided...
In a Java program, how could I write a program that can assign values that would...
In a Java program, how could I write a program that can assign values that would make a rock paper scissors game work? I have a program that will generate a computer response of either rock, paper, or scissors but how can I compare a user input of "rock", "paper", or "scissors" so that we can declare either the user or the computer the winner.
A humanities professor sent a letter grade on a test according to the following scheme. A:...
A humanities professor sent a letter grade on a test according to the following scheme. A: top 12% scores. B: Score is below 12% and above the bottom 58%. C: score is below the top 42% and above the bottom 25% . D: scores below top 75% and above bottom 8% . F: bottom 8% of scores. Scores on tests are normally distributed with a mean of 78.9 and a standard deviation of 9.3.Find the minimum score required for an...
Methods – Compute Grade Please write a complete Java program, given the following information about (a...
Methods – Compute Grade Please write a complete Java program, given the following information about (a few lines of code in) main: projectAverage = getAverage(”Project”); // returns average of 2 grades testAverage = getAverage(”Test”); // returns average of 2 grades displayGrade(projectAverage, testAverage); // test are 70% & projects 30%
Use if statements to write a Java program that inputs a single letter and prints out...
Use if statements to write a Java program that inputs a single letter and prints out the corresponding digit on the telephone. The letters and digits on a telephone are grouped this way: 2 = ABC    3 = DEF   4 = GHI    5 = JKL 6 = MNO   7 = PRS   8 = TUV 9 = WXY No digit corresponds to either Q or Z. For these 2 letters your program should print a message indicating that they are not...
Write a program in java processing. Write a program that does the following: · Assume the...
Write a program in java processing. Write a program that does the following: · Assume the canvas size of 500X500. · The program asks the user to enter a 3 digit number. · The program then checks the value of the first and last digit of the number. · If the first and last digits are even, it makes the background green and displays the three digit number at the mouse pointer. · If the two digits are odd, it...
Write a complete program in java that will do the following:
Write a complete program in java that will do the following:Sports:             Baseball, Basketball, Football, Hockey, Volleyball, WaterpoloPlayers:           9, 5, 11, 6, 6, 7Store the data in appropriate arraysProvide an output of sports and player numbers. See below:Baseball          9 players.Basketball       5 players.Football           11 players.Hockey            6 players.Volleyball        6 players.Waterpolo       7 players.Use Scanner to provide the number of friends you have for a team sport.Provide an output of suggested sports for your group of friends. If your...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT