subject

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));}}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:30
Experimental data that is expressed using numbers is said to be
Answers: 1
question
Computers and Technology, 24.06.2019 15:20
Local area networks use many of the same network technologies and the internet, only on a smaller scale. devices that access lans are equipped with a network interface that contains circuitry for wireless or wired connections. devices also have a physical address, in addition to the ip addresses acquired from a dhcp server. the most popular wired technology is . the most popular wireless technology is , which can be configured as a(n) or star topology. setting up a lan and configuring its router is fairly easy. the first step is to change the standard to one that is secure. next, create a(n) that uniquely identifies the network by name. it is also important to activate wireless to prevent wireless signals from being intercepted during transmission. a limited-access network can be created for visitors to use. by activating , the router will be able to assign ip addresses to each device that joins the network. to connect to a secure lan that is protected by encryption, an encryption , or password, is required. lans can be used to access data collected by iot devices and the networks that tie these devices together. technologies such as rfid, nfc, bluetooth smart, zigbee, and z-wave offer -power links, essential for battery-powered devices that can’t expend excess amounts of energy transmitting data.
Answers: 1
question
Computers and Technology, 25.06.2019 04:20
Many prestigious universities have a system called a “legacy preference system” which is used to decide which applicants should be accepted to the university. if an applicant’s parent is an alumnus of the university, the applicant will be admitted with lower gpa and sat scores than if the parent is not an alumnus. (there is currently a lot of discussion about the fairness of this system, but universities get a lot of money from their alumni so they are unwilling to change ) your assignment for mp2 is to implement a computerized system like this for a very small prestigious university. the university has two schools, liberal arts and music, each with their own criteria for accepting students. your program must read in certain information about an applicant and print a message saying whether the applicant should be accepted or not.
Answers: 2
question
Computers and Technology, 26.06.2019 07:00
To use object snap tracking ( otrack ), where would you go turn it on for use in an autocab drawing? a) shortcut menu b) application menu c) quick access toolbar d) status bar
Answers: 1
You know the right answer?
Test Average and Grade Write a program that asks the user to enter five test scores. The program s...
Questions
question
Advanced Placement (AP), 04.08.2019 18:30
question
Mathematics, 04.08.2019 18:30
Questions on the website: 13722363