|
| tamekawill (2) | |
| /* Tameka Williams * X-treme scoring program * */ #include <iostream> // I/O. #include <sstream> // string stream. #include <string> // string class. #include <stdlib.h> using namespace std; int main() { //declare variables. double score1, score2, score3, score4, hi_score, lo_score, event_score; int country_n, difficulty; std::string country; // Get values from the input. cout << "Please enter the Country number, first score, second score, third score, fourth score, and difficulty" << endl; cin >> country_n >> score1 >> score2 >> score3 >> score4 >> difficulty; // Statements. do { // asign country. if(country_n == 1) country = ("USA"); if(country_n == 2){ country = ("CANADA"); }; if (country_n == 3) country = ("AUSTRALIA"); if(country_n == 4){ country = ("NEW_ZEALAND"); }; // calculate the highest score given. hi_score = score1; if (score2 > hi_score) hi_score = score2; if (score3 > hi_score) hi_score = score3; if (score4 > hi_score) hi_score = score4; //Calculate the lowest score given. lo_score = score1; if (score2 < lo_score) lo_score = score2; if (score3 < lo_score) lo_score = score3; if (score4 < lo_score) lo_score = score4; //calculate Event Score. event_score=(((score1+score2+score3+score4)-(hi_score+lo_score))/2)*difficulty; //output. cout <<"Country "<< country << '\n'; cout <<"Lowest Score "<< lo_score << '\n'; cout <<"highest Score "<< hi_score << '\n'; cout <<"Event Score "<< event_score << '\n'; cout <<" "<<'\n'; cout << "Please enter the Country number, first score, second score, third score, fourth score, and difficulty" << endl; cin >> country_n >> score1 >> score2 >> score3 >> score4 >> difficulty; } while(country_n > 0 || country_n <= 4);//end loop. system("pause"); return 0; } //end main | |
| Alex B (20) | |
| It compiles for me on Dev-C++. Also, it looks like the only file you need to include is <iostream> and you don't need the other three, unless if you plan on using them later. That could possibly get ride of the <sstream> error. And did you know you have no way of exiting the program? The expression "country_n > 0 || country_n <= 4" is always true, because any number is always greater than 0 or less than 4, therefore the do-while loop is infinite. | |
| tamekawill (2) | |
| Thanks for the info. I had a problem with my Dev-C++ program and had to reinstall. I was able to run the program with no problem and thanks for the heads up on the exiting situation, I will look into it. | |
This topic is archived - New replies not allowed.
