I am having a problem with this program assiging a letter grade given a numeric score. The program should continue accepting a value until a negative number(ANY negative number) is input. Have to use the If-else, if-else construct. The program should print how many As, Bs, etc. were assigned. It is not working properly. When I compile the program it has no errors. When I run it, it prints the same line over and over and won't stop. Please help. What am I doing wrong?
Code:
#include<stdio.h>
void main(void)
////////////////////* Declare and Intialize variable *///////////////////////////////
{ int score, a_s, b_s, c_s, d_s, f_s, grades_total;
a_s = 0; b_s = 0; c_s = 0; d_s = 0; f_s = 0;
////////////////////* User Input Values *////////////////////////////////////////////
printf("Enter a score: ");
scanf("%i", &score);
while(score != -1)
{
if(score >=93)
{ printf(" A score of 100-93 is a(n) A\n");
++a_s;
}
else if(score >= 92)
{ printf(" A score of 92-90 is a(n) A-\n");
++a_s;
}
else if(score <= 89)
{ printf(" A score of 89-87 is a(n) B+\n");
++b_s;
}
else if(score <= 86)
{ printf(" A score of 86-83 is a(n) B\n");
++b_s;
}
else if(score <= 82)
{ printf(" A score of 82-80 is a(n) B-\n");
++b_s;
}
else if(score <= 79)
{ printf(" A score of 79-77 is a(n) C+\n");
++c_s;
}
else if(score <= 76)
{ printf(" A score of 76-73 is a(n) C\n");
++c_s;
}
else if(score <= 72)
{ printf(" A score of 72-70 is a(n) C-\n");
++c_s;
}
else if(score <= 69)
{ printf(" A score of 69-67 is a(n) D+\n");
++d_s;
}
else if(score <= 66)
{ printf(" A score of 66-63 is a(n) D\n");
++d_s;
}
else if(score <= 62)
{ printf(" A score of 62-60 is a(n) D-\n");
++d_s;
}
else if(score <= 59)
{ printf(" A score of 59 and below is a(n) F\n");
++f_s;
}
printf("Enter a score: ");
scanf("i%", &score);
}
printf("Grade Summary\n");
printf("-------------\n");
printf("%i A's (A, A-)\n", a_s);
printf("%i B's (B+, B, B-)\n", b_s);
printf("%i C's (C+, C, C-)\n", c_s);
printf("%i D's (D+, D, D-)\n", d_s);
printf("%i F's\n", f_s);
printf("-------------------\n");
grades_total = a_s + b_s + c_s + d_s + f_s;
printf("%i (grades total)", grades_total);
}