Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++: Assume that grade is a variable whose value is a letter grade-- any one of

ID: 642624 • Letter: C

Question

C++: 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.

Explanation / Answer

C++: 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.

int acount, bcount, ccount, dcount, ecount, fcount, wcount, icount;

switch(grade){
   case 'A': acount++; break;
   case 'B': bcount++; break;
   case 'C': ccount++; break;
   case 'D': dcount++; break;
   case 'E': ecount++; break;
   case 'F': fcount++; break;
   case 'W': wcount++; break;
   case 'I': icount++; break;
   default: break;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote