### Still having problems with this one assignment loop/if/else statement

Here is the assignment below.

And here is the code below.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990`` ``````#include #include using namespace std; int main( ) { int acount=0, bcount=0, ccount=0, dcount=0, fcount=0; double score, totalStudents; string name; cout <<"Enter a name "<< endl; cin>> name; cout <<"Enter a score" << endl; cin>> score; while(name!="//") { if(score >=90.0) { acount = acount+1; cout<=80.0) { bcount = bcount+1; cout<=70.0) { ccount = ccount+1; cout<=60.0) { dcount = dcount+1; cout<=0-59.0) { fcount = fcount+1; cout<

So, what exactly am I doing wrong? I must admit, some things about looping and if/else statement confuse me. My professor recommended the brackets wrapping around a piece of if/else code, but I get an error message from the compiler. Any thoughts? Suggestions?
this `else(score>=80.0)`

should be `else if(score>=80.0)`

Same for all the other ones

E: You are not incrementing `totalStudents`, so that will return some random value

Line 79:
You used a variable that was not declared `totalStudent = name`

E2: Line 14-17 should be inside your while loop and use `getline(cin, name)` instead of `cin >> name`
Last edited on
Ok, fixed some of the errors, but it is having a numerical conflict between 'double' and 'constant' char to binary operator<<

Not sure what to make of it. LOL, I'm totally lost.
Paste the new code :D
 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364`` ``````#include #include using namespace std; int main( ) { int acount=0, bcount=0, ccount=0, dcount=0, fcount=0; double score; string name; while(name!="//") { cout <<"Enter a name "<< endl; cin>>name; cout <<"Enter a score" << endl; cin>>score; if(score>=90.0) { acount = acount+1; cout<=80.0) { bcount = bcount+1; cout<=70.0) { ccount = ccount+1; cout<=60.0) { dcount = dcount+1; cout<=0-59.0) { fcount = fcount+1; cout<

Here is the more recent code.
Inside the d and f count else-if blocks you're missing a < right before the word "score".

Also, your last else-if probably wants to be score < 60.
Last edited on
I don't know if this will be of any help but I wanted to give this assignment a go so here's the code:

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374`` ``````#include #include #include #include using namespace std; int main(){ int acount=0, bcount=0, ccount=0, dcount=0, fcount=0; double score; string name; int pamount = 0; while(name != "//"){ cout << "Enter a name: "; cin >> name; if(name == "//"){ break; } cout << endl << "Enter a score: "; cin >> score; if(score >= 90.0){ pamount++; acount++; cout << name << " " << score << " A" << endl; } else if((score <= 89.0), (score >=80.0)){ pamount++; bcount++; cout << name << " " << score << " B" << endl; } else if((score <= 79.0), (score >= 70.0)){ pamount++; ccount++; cout << name << " " << score << " C" << endl; } else if((score <= 69.0), (score >=60.0)){ pamount++; dcount++; cout << name << " " << score << " D" << endl; } else if(score <=59.0){ pamount++; fcount++; cout << name << " " << score << " F" << endl; } } cout << "Summary Report" << endl; cout << "Total number of students: " << pamount << endl; cout << "Total students receiving grade A: " << acount << endl; cout << "Total students receiving grade B: " << bcount << endl; cout << "Total students receiving grade C: " << ccount << endl; cout << "Total students receiving grade D: " << dcount << endl; cout << "Total students receiving grade F: " << fcount << endl; }``````

I first tried using getline(cin,name); but it made the program skip the name input after the first input. No idea why :)
Also some of the includes may not be required ;)

I think that it works as it should.
Topic archived. No new replies allowed.