I'm trying to learn quickly through a great book, experimenting along the way and trying new codes out on top of the ones given in the exercises. But this one I can't figure out. I want a congratulation message to show if the average is above a certain amount. Here is what I wrote, it works until I try to get the if/else to get the total and show the appropriate message. Thank you!
//Game averager program, my intentions are to get the input from three separate 'scores and average them at the end
#include <iostream>
#include <string>
using namespace std;
int a,b,c;
int main()
{
//Input requests
cout<<"Please enter your first score: ";
cin>>a;
cout<<"Please enter your second score: ";
cin>>b;
cout<<"Please enter your third score: ";
cin>>b;
string total;
cout<<"Total: "<<(a+b+c)/3<<"\n\n";
//Success or Failure messages
if (total>="100")
{
cout<<"You passed, please move on to the next level\n";
}
else
{
cout<<"You failed, please try again\n\n";
}
1. Declare a variable: int average;
2. After you get the 3 scores from the user have average = (a+b+c)/3;
3. You can then cout << average;
4. What are you trying to do with total? It shouldn't be a string, make it an int. If the purpose of total is to be the average then apply the above steps.