assume that grade is a variable whose value is a letter grade-- anyone of the fo
ID: 3653856 • Letter: A
Question
assume that grade is a variable whose value is a letter grade-- anyone of the following letters: 'A', 'B', 'C', 'D', 'E', 'F', 'W', 'I'. Assume further there are the following int variables, declared an already initialized: account, bcount, ccount, dcount, ecount, fcount, wcount, icount. Write a switch statement that increments the apropiate variable (acount, bcount, ccount, etc..) depending on the value of grade. So if grade is 'A' then acount is incremented; if grade is 'B' then bcount is incremented and so on.Explanation / Answer
Assume that grade is a variable whose value is a letter grade-- any one of the following letters: 'A', 'B', 'C', 'D', 'E', 'F', 'W', 'I'. Assume further that there are the following int variables, declared and already initialized: acount, bcount, ccount, dcount, ecount, fcount, wcount, icount.
Write a switch statement that increments the appropriate variable (acount, bcount, ccount, etc.) depending on the value of grade. So if grade is 'A' then acount is incremented; if grade is'B' then bcount is incremented, and so on.
Is this what you mean?
switch(grade)
{
case 'A':
acount++;
break;
case 'B':
bcount++;
break;
.
.
.
.
default:
icount++;
break;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.