Menu

[solved]-Anybody Tell Logical Errors Got Output Q39046770

7. Test Average and Grade Write a program that asks the user to enter five test scores. The program should display a letter gimport java.util.Scanner; 4 public class TestAvgAndGrade public static double calcAverage (double userScorei, double userscorpublic static void main(String[] args) @SuppressWarnines (resource) Scanner scanner - new Scanner(System.in); int numberOfScCODELAB ANALYSIS: LOGICAL ERROR(S) Problems Detected: - The contents of your standard output is incorrect. Given the followin

Can anybody tell me why? Logical Errors?I got same output.

7. 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 SAMPLE RUN #4: java TestAvgAndGrade Interactive Session Hide Invisibles Highlight: None Highlight: None Show Highlighted Only Enter test grade. for student. 1:55. Enter-test.arade. for student. 2:654 Enter-test-grade. for student. 3:754 Enter-test-grade. for student.4:85- Enter test erade. for student.5:954 -The-letter.grades are as follows: Student.1:. Student.2:-D Student. 3. Student.4:. Student.5:- AJ The average.grade was: -75.00- import java.util.Scanner; 4 public class TestAvgAndGrade public static double calcAverage (double userScorei, double userscore2, double userScore3, double userScore4, double userScore5) double average; average- (user Scorel + user Score2 + user Score return average; + user Score4 + userScores) / 5; public static string determineGrade(double testscore) String letterGrade – “”; if (testScore >= 90 && testScore <= 100) letterGrade -“A”; else if (testScore >= 30 && testScore <= 89) letterGrade – “B”; testscore <- 79) else if (testscore >- 78 & letterGrade = “C”; else if (testScore >- 60 && testScore <- 69) letterGrade – “D”; else letterGrade – “F”; return letterGrade; public static void main(String[] args) SuppressWarnines (“resource) Scanner scanner = new Scanner(System.in); int nunberoScores – 5 public static void main(String[] args) @SuppressWarnines (“resource) Scanner scanner – new Scanner(System.in); int numberOfScores = 5: double userscore; double userScorel = 3; double userscorez – double userScore3 = 3; double userscore4 – ; 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: userScorel – userscore; outputString += “Student 1: ” + determineúrade(userScorel) – “n”; break: case 2: userScore2 -userscore; outputString = “Student 2: ” + determinerade(userScore2) . “n”; break; case 3: userscore3 – user5core; outputString – “Student 3: ” + determineGrade(user Score3) – “n”; break; userscore – UserScore: outputString = “Student 4: ” + determine Grade(user Score) . “n”; break; case 5: userScores – userScore; outputString +- “Student 5: ” + determine Grade(userScore5) – “n”; break; default: 93 break; System.out.print(outputString); System.out.print(“The average grade was: – String.format(“%.2f”, calcAverage(userScorel, userscorez, userscore3, userscore4, userscore5))); 102 104 ? CODELAB ANALYSIS: LOGICAL ERROR(S) Problems Detected: – The contents of your standard output is incorrect. Given the following was entered from the keyboard: you displayed: Enter test grade for student 1: Enter test grade for student 2: Enter test grade for student 3: Enter test grade for student 4: Enter test grade for student 5: The letter grades are as follows: Student 1: F Student 2: F Student 3: D Student 4: C Student 5: B The average grade was: 52.60 instead of: Enter test grade for student 1: Enter test grade for student 2: Enter test grade for student 3: Enter test grade for student 4: Enter test grade for student 5: The letter grades are as follows: Student 1: F Student 2: F Student 3: D Student 4: C Student 5: B The average grade was: 52.60 Show transcribed image text 7. 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 SAMPLE RUN #4: java TestAvgAndGrade Interactive Session Hide Invisibles Highlight: None Highlight: None Show Highlighted Only Enter test grade. for student. 1:55. Enter-test.arade. for student. 2:654 Enter-test-grade. for student. 3:754 Enter-test-grade. for student.4:85- Enter test erade. for student.5:954 -The-letter.grades are as follows: Student.1:. Student.2:-D Student. 3. Student.4:. Student.5:- AJ The average.grade was: -75.00-
import java.util.Scanner; 4 public class TestAvgAndGrade public static double calcAverage (double userScorei, double userscore2, double userScore3, double userScore4, double userScore5) double average; average- (user Scorel + user Score2 + user Score return average; + user Score4 + userScores) / 5; public static string determineGrade(double testscore) String letterGrade – “”; if (testScore >= 90 && testScore = 30 && testScore – 60 && testScore

Expert Answer


Answer to Can anybody tell me why? Logical Errors?I got same output…. . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *