Computers and Technology

Test Average and Grade Write a program that asks the user to enter five test scores. The program should display a
letter grade for each score and the average test score. Write the following methods in the
program:
calcAverage:
This method should accept five test scores as arguments and return the
average of the scores.
determineGrade:
This method should accept a test score as an argument and return a
letter grade for the score, based on the following grading scale:
Score Letter Grade
90-100 A
80-89 B
70-79 C
60-69 D
Below 60 F
Expected Output:
Enter·test·grade·for·student·1:55↵ ·
Enter·test·grade·for·student·2:65↵ ·
Enter·test·grade·for·student·3:75↵ ·
Enter·test·grade·for·student·4:85↵ ·
Enter·test·grade·for·student·5:95↵ ·
The·letter·grades·are·as·follows:↵< br /> Student·1:·F↵
Student·2:·D↵
Student·3:·C↵
Student·4:·B↵
Student·5:·A↵
The·average·grade·was:·75.00↵
ISSUES: PLEASE HELP:
I can not get the student's letter grade to display correctly;
I can not get the average to calculate correctly;
Instructions states to write the METHODS in the program.
My output:
Enter test grade for student 1:50
Enter test grade for student 2:60
Enter test grade for student 3:70
Enter test grade for student 4:80
Enter test grade for student 5:90
The letter grades are as follows:
Student 0.0F
Student F
Student F
Student F
Student F
Average:0.0
My Code:
import java. util. Scanner;
public class TestAveGrade{
public static double calcAverage(double userScore1, double userScore2, double userScore3, double userScore4, double userScore5){
double average;
average = (userScore1 +userScore2 +userScore3 +userScore4 +userScore5) /5;
return average;
}
public static String determineGrade(double testScore){
String letterGrade = " ";
if (testScore < 60){
letterGrade = "F";
} else if (testScore <70) {
letterGrade = "D";
}else if (testScore <80) {
letterGrade = "C";
}else if (testScore <90) {
letterGrade = "B";
}else if (testScore <100) {
letterGrade = "A";
}
return letterGrade;
}
public static void main( String [] args) {
Scanner scanner = new Scanner( System. in );
int numberOfScores = 5;
double userScore;
double userScore1 = 0;
double userScore2 = 0;
double userScore3 = 0;
double userScore4 = 0;
double userScore5 = 0;String outputString = "The letter grades are as follows:\n";for(int currentScore = 1; currentScore <= numberOfScores; currentScore++){System. out. print ("Enter test grade for student " + currentScore+":");userScore = scanner. nextDouble();switch (currentScore) {case 1:userScore1 = userScore1;outputString += "Student "+ userScore1 + determineGrade( userScore1) +"\n";break;case 2:userScore2 = userScore2;outputString += "Student "+ determineGrade (userScore2) + "\n";break;case 3:userScore2 = userScore3;outputString += "Student "+ determineGrade (userScore3) + "\n";break;case 4:userScore2 = userScore4;outputString += "Student "+ determineGrade (userScore4) + "\n";break;case 5:userScore2 = userScore5;outputString += "Student "+ determineGrade (userScore5) + "\n";break;default:break;}}System. out. print( outputString + "Average:" + calcAverage (userScore1, userScore2, userScore3, userScore4, userScore5));}}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 03:00, seddy86
Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". any value that is the same as the immediately preceding value is considered a consecutive duplicate. in this example, there are three such consecutive duplicates: the 2nd and 3rd 5s and the second 6. note that the last 3 is not a consecutive duplicate because it was preceded by a 7. write some code that uses a loop to read such a sequence of non-negative integers , terminated by a negative number. when the code finishes executing, the number of consecutive duplicates encountered is printed. in this case, 3 would be printed. assume the availability of a variable, stdin, that references a scanner object associated with standard input. that is, stdin = new scanner(system. in); is given.
Answers: 1
image
Computers and Technology, 23.06.2019 02:00, rah45
Which of the following is not a source of sustainable raw materials? a) coal mine b) flick of sheep c) cotton plantation d) line forest.
Answers: 2
image
Computers and Technology, 23.06.2019 09:30, jason9394
Facial expressions and gestures are examples of messages.
Answers: 3
image
Computers and Technology, 23.06.2019 17:30, Artemis3821
Scientists have changed the model of the atom as they have gathered new evidence. one of the atomic models is shown below. what experimental evidence led to the development of this atomic model from the one before it? a few of the positive particles aimed at a gold foil seemed to bounce back. the colors of light emitted from heated atoms had very specific energies. experiments with water vapor showed that elements combine in specific proportions. cathode rays were bent in the same way whenever a magnet was brought near them.
Answers: 2
Do you know the correct answer?
Test Average and Grade Write a program that asks the user to enter five test scores. The program s...

Questions in other subjects:

Konu
English, 25.10.2019 03:43
Konu
Mathematics, 25.10.2019 03:43
Konu
Chemistry, 25.10.2019 03:43