I am creating a program which includes converting numerical grades to letter grades but I'm stuck where I have to put a counter that counts number of letters. For example if 90-100=A and 90, 96, 87, 96 are entered, to count and display something like Number of As= 4
or something similar. I am doing this for other letters such as 80s=B 70s=C etc. I have no idea how to use the counter.
I need a simple counter code to use. All I remember was something about countAs = 0;
and maybe something about 1+ somewhere in there. I am completely lost on the counters.
#include <iostream>
using namespace std;
main ()
{
int studentgrade1;
int countAs = 0;
int countBs = 0;
int countCs = 0;
int countDs = 0;
cout << "enter student grade: ";
cin >> studentgrade1;
if (studentgrade1 >= 90) cout<<"A";
else if (studentgrade1 >= 80) cout<<"B";
else cout <<"failed";
//If the person enters, 95, that is an A. Then program should notice and count there's 1 a so far
cout << "enter student grade: ";
cin >> studentgrade1;
//Enters a new grade and if person enters 92, that is an A and then program should count that there's another A
if (studentgrade1 >= 90) cout<<"A";
else if (studentgrade1 >= 80) cout<<"B";
else cout<<"failed";
//program should then display results of how many As and Bs Etc. there were.
return 0;
}
I wrote this code as an example. I know I have to fill out the others for 80s, 70s and write more code and but just focusing on how I could go about it in terms of displaying how many As, Bs, Cs etc were converted? Thanks!