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

Write a program that translates a letter grade into a number grade. Letter grades are A,...
Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D, and F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1 and 0. There is no F+ or F-. A “+” increases the numeric value by 0.3, a “–“ decreases it by 0.3. However, an A+ has value 4.0.4 pts Enter a Letter grade: B- The numeric value is 2.7 Your code with comments A screenshot...
(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 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...
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"...
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 Java program that asks a user to input a letter, converts the user input to...
Write Java program that asks a user to input a letter, converts the user input to uppercase if the user types the letter in lowercase, and based on the letter the user the user enters, display a message showing the number that matches the letter entered. For letters A or B or C display 2 For letter D or E or F display 3 For letter G or H or I display 4 For letter J or K or L...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT