Question

Find the errors in the following code: / / Warning! This code contains ERRORS! switch (score)...

Find the errors in the following code:

/ / Warning! This code contains ERRORS!
switch (score)
{
case (score > 90):
grade = 'A';
break;
case(score > 80):
grade = 'B';
break;
case(score > 70):
grade = 'C';
break;
case (score > 60):
grade = 'D';
break;
default:
grade = 'F';
}

*Submit in Java format

0 0
Add a comment Improve this question Transcribed image text
Answer #1

if (score > 90) {

    grade = 'A';

}

else if(score > 80){

    grade = 'B';

}

else if(score > 70){

    grade = 'C';

}

else if(score > 60){

    grade = 'D';

}

else {

    grade = 'F';

}

FOR CHECKING MARKS USE IF-ELSE, INSTEAD OF SWITCH CASE.

FOR HELP PLEASE COMMENT.
THANK YOU

Add a comment
Know the answer?
Add Answer to:
Find the errors in the following code: / / Warning! This code contains ERRORS! switch (score)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Find the errors in following program. //This program uses a switch statement to assign a //...

    Find the errors in following program. //This program uses a switch statement to assign a // letter grade (A, B, C, D, or F) to numeric test score. #include <iostream> uisng namespace std; int main() { int testScore; cout<<"Enter your test score and I will tell you\n"; cout<<"the letter grade you earned: "; cin>>testScore; switch (testScore) { case (testScore < 60) cout<<"Your grade is F.\n"; break; case (testScore <70) cout<<"Your grade is D.\n" break; case (testScore <80) cout<<"Your grade is...

  • Today assignment , find the errors in this code and fixed them. Please I need help...

    Today assignment , find the errors in this code and fixed them. Please I need help with find the errors and how ro fixed them. #include <iostream> #include <cstring> #include <iomanip> using namespace std; const int MAX_CHAR = 100; const int MIN_A = 90; const int MIN_B = 80; const int MIN_C = 70; double getAvg(); char determineGrade(double); void printMsg(char grade); int main() { double score; char grade; char msg[MAX_CHAR]; strcpy(msg, "Excellent!"); strcpy(msg, "Good job!"); strcpy(msg, "You've passed!"); strcpy(msg, "Need...

  • R3.3 Find the errors in each of the following if statements. a. if x 〉 e...

    R3.3 Find the errors in each of the following if statements. a. if x 〉 e then System.out.print(x); b, if (1 + x > Math . pow(x, Math.sqrt(2)) { y = y + x; c.if(x=1) { y++; } d. x = in·nextInt(); if (in.hasNextInt()) sum = sum + x; else System.out.println("Bad input for x"); e. String letterGrade = "F"; if (grade 〉= 90) { letterGrade _ "A"; } if (grade 〉= 80) { letterGrade- "B"; } if (grade 〉= 70)...

  • Find the error in the following java code and explain how to correct it (val is...

    Find the error in the following java code and explain how to correct it (val is a variable of type int): switch (val) { case 1: System.out.println ("The number is 1"); case 2: System.out.println ("The number is 2"); default: System.out.println ("The number is not 1 or 2"); break;

  • What is the output of the following pseudo-code segment? A, B, C, or None of the...

    What is the output of the following pseudo-code segment? A, B, C, or None of the above ** In pseudo-code, you ignore syntax errors and focus on the logic ** score = 60 if (score >= 70) print "C" else if (score >= 80) print "B" else if (score >= 90) print "A" and score = 105 if (score >= 90 && score <= 100) print "A" else if (score >= 80) print "B" else print "C"

  • using if/switch statements (C++) Write a grading program for a class with the following grading policies:...

    using if/switch statements (C++) Write a grading program for a class with the following grading policies: There are two quizzes, each graded on the basis of 10 points There is one midterm exam and one final exam, each graded on the basis of 100 points The final exam counts for 50% of the grade, the midterm counts for 25% and the two quizzes together count for a total of 25%. (Do not forget to normalize the quiz scores. They should...

  • Please code in JAVA Generate an output1 that contains the capital case name + average score....

    Please code in JAVA Generate an output1 that contains the capital case name + average score. Quiz1.txt Ricky 80 Becky 79 Nicky 90 Quiz2.txt Ricky 90 Becky 88 Nicky 100 Output.txt RICKY 85.00 BECKY 83.50 NICKY 95

  • Q3) (20 Mark) A student's test score T is an integer between 0 and 100 corresponding...

    Q3) (20 Mark) A student's test score T is an integer between 0 and 100 corresponding to the experimental outcomes s0; s1,., s100. A score of 90 to 100 is an A, 80 to 89 is a B, 70 to 79 is a C, 60 to 69 is a D, and below 60 is a failing grade of F. If all scores between 51 and 100 are equally likely and a score of 50 or less never occurs, find the...

  • Consider the following statements. If the input is 95, the output of the following code will...

    Consider the following statements. If the input is 95, the output of the following code will be: #include <iostream> #include <string> using namespace std; int main ) { float score; string grade; cin >> score; grade - "Unknown"; if (score >= 90) grade - "A"; if (score > 80) grade - "B"; if (score > 70) grade - "C"; else grade - "F"; cout << grade; }

  • Java debugging in eclipse package edu.ilstu; import java.util.Scanner; /** * The following class has four independent...

    Java debugging in eclipse package edu.ilstu; import java.util.Scanner; /** * The following class has four independent debugging * problems. Solve one at a time, uncommenting the next * one only after the previous problem is working correctly. */ public class FindTheErrors { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); /* * Problem 1 Debugging * * This problem is to read in your first name, * last name, and current year and display them in *...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT