the if statment is still being printed
Jan 23, 2011 at 3:32am UTC
The if statment that starts on line 33 is being read and printed even though the condition is not being met. I have tried everything even trying to turn it into a while loop, but the same thing keeps happening.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
string divers, city;
double highest, lowest, overall, diff, total;
double score;
int counter;
char proceed;
do
{
cout << "Input the divers name" << endl;
getline (cin, divers);
cout << "Enter the diver's city" << endl;
getline (cin, city);
highest = -1;
lowest = 11;
total = 0;
counter = 0;
overall = 0;
do
{
cout << "Please enter a score between 1 and 10" << endl;
cin >> score;
if (score < 0 || score > 10);
{
cout << "invalid score please enter a score between 1 and 10" << endl;
cin >> score;
}
if (score > highest)
highest = score;
if ( score < lowest)
lowest = score;
counter++;
overall += score;
}while (counter < 5);
cout << "Please input the degree of difficulty between 1 and 1.67" << endl;
cin >> diff;
while (diff < 0 || diff > 1.67)
{
cout << "Invalid degree of difficulty _ Please reenter (Valid Range: 1 - 1.67)" << endl;
cin >> diff;
}
overall = (overall - (highest + lowest) * diff)/3 * diff;
cout << divers << city << endl;
cout << "Overall score was " << overall;
cout << "Do you want to process another diver (Y/N) ?" << endl;
cin >> proceed;
} while (proceed == 'y' || proceed == 'y' );
return 0;
}
Jan 23, 2011 at 3:35am UTC
Remove the semicolon at the end of that line?
Jan 23, 2011 at 3:37am UTC
Thanks. I did not see that at all.
Topic archived. No new replies allowed.