I have a c++ program I am creating. The user is taking an input file that has a
ID: 3668119 • Letter: I
Question
I have a c++ program I am creating.
The user is taking an input file that has a Student ID, their assignments percent grade, their exam 1 percent grade, their exam 2 percent grade, and their final exam percent grade.
The program computes the students percent grade for the whole class after exam 2 and also after the final exam. After computing the percent grade, the letter grade is output (A,B,C,D,F). The program requires that the program counts and prints out the amount of A's and B's there are.
I had to create a header file, implementation file, and main program file. Everything is working correctly, the only thing I'm having an issue is how to create a counter for counting the number of A's and B's there are. I made the A's and B's characters, so I really just need to know how to create a counter that counts the amount of A's and B's, which happen to be Chars.
Any help would be appreciated!
Explanation / Answer
here is the sample counter code which can count your A's and B's.
{
38
char Ch, PrevChar;
39
int CharCount = 0, Counter[16];
40
41
Ch = cin.get();
42
43
while(!cin.eof())
44
{
45
cout<<Ch;
46
CharCount++;
47
PrevChar = Ch;
49
Ch = cin.get();
if((Ch == (' '||' '||' '||'')) && (PrevChar != (' '||' '||' ')))
{
++Counter[CharCount];
CharCount = 0;
}
}
return Counter[16];
}
int WordLength()Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.