Kindly fix the errors in this assignment I'm getting an error on error: expected ' ' before ' ' } else if (grade == 'B') {  (I cannot see the error) [ Here is the assignement ]  Write an structure that will print a message based on the grade ( A,B,C,D,or F). Do this first using an if statement. Then do it using a switch statement. The grade and message are as follows. • A Excellent Job • B Very Good • C Average • D Need more effort   ------- code ------- #include int main() { char grade;           printf("please enter your grade (A, B,C,D, or F): ");         scanf("%c", &grade);   // Using if statement if (grade == 'A'){         printf("Excellent job!\n");{ } else if (grade == 'B') {         printf("Very good!\n"); } else if (grade == 'C') {         printf("Average. n"); } else if (grade == 'D') {         printf("You need more effort.\n"); } else if (grade == 'F') {         printf("You need to get some help. \n"); } else {         printf("Invalid grade entered.\n"); } // Using switch statement switch (grade) { case 'A':         printf("Excellent job\n");         break; case 'B':         printf("Very good\n");         break; case 'C':         printf("Average. \n");         break; case 'D':         printf("You need more effort. \n");         break; case 'F':         printf("You need to get some help. \n");         break; default:         printf("Invalid grade entered.\n");         break; }         return

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 16RQ
icon
Related questions
Question

Kindly fix the errors in this assignment

I'm getting an error on error: expected ' ' before ' '
} else if (grade == 'B') {

 (I cannot see the error)

[ Here is the assignement ] 
Write an structure that will print a message based on the grade ( A,B,C,D,or F). Do this first using an if statement. Then do it using a switch statement. The grade and message are as follows. • A Excellent Job • B Very Good • C Average • D Need more effort

 

------- code -------

#include <stdio.h>

int main() {
char grade;
 
        printf("please enter your grade (A, B,C,D, or F): ");
        scanf("%c", &grade);
 
// Using if statement
if (grade == 'A'){
        printf("Excellent job!\n");{
} else if (grade == 'B') {
        printf("Very good!\n");
} else if (grade == 'C') {
        printf("Average. n");
} else if (grade == 'D') {
        printf("You need more effort.\n");
} else if (grade == 'F') {
        printf("You need to get some help. \n");
} else {
        printf("Invalid grade entered.\n");
}

// Using switch statement

switch (grade) {
case 'A':
        printf("Excellent job\n");
        break;
case 'B':
        printf("Very good\n");
        break;
case 'C':
        printf("Average. \n");
        break;
case 'D':
        printf("You need more effort. \n");
        break;
case 'F':
        printf("You need to get some help. \n");
        break;
default:
        printf("Invalid grade entered.\n");
        break;
}
        return 0;

}

 

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT