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
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
Find the errors in the following code: / / Warning! This code contains ERRORS! switch (score)...
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...
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";...
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...
What is the value of GPA when grade is 'B' in the following code segment? int GPA=0; switch (grade) { case 'A': case 'a': GPA = GPA + 1; case 'B': case 'b': GPA = GPA + 1; case 'C': case 'c': GPA = GPA + 1; case 'D': case 'd': GPA = GPA + 1; } 4 3 2 1 None of the above #2. Branching - switch statements... Extra info/hint? It's free What is the value of GPA when...
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)...
The switch Statement C++program This lab work with the switch statement. • Remove the break statements from each of the cases. What is the effect on the execution of the program? • Add an additional switch statement that allows for a Passing option for a grade of D or better. Use the sample run given below to model your output. Sample Run: What grade did you earn in Programming I? YOU PASSED! An A - excellent work! The following is...
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"
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;
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...
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...