Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by Bryan Thomas ( 15 years ago )
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main() {
string name,team, winner;
string blue_team[4],white_team[4];
int score, blue_score=0,white_score=0;
int blue_scores[3], white_scores[3];
int b=0,w=0;
ifstream bowl;
bowl.open("Scores.txt");
if(!bowl) {
cerr << "Error: File not opened!";
exit(1);
}
while(!bowl.eof()) {
bowl >> name;
bowl >> team;
bowl >> score;
if(team == "Blue") {
blue_team[b] = name;
blue_scores[b] = score;
blue_score = (blue_score+score);
b++;
} else {
white_team[w] = name;
white_scores[w] = score;
white_score = (white_score+score);
w++;
}
} // END OF WHILE
if(blue_score > white_score) {
winner = "Blue";
} else {
winner = "White";
}
cout << endl << "This program decides which bowling team wins a tournament." << endl;
cout << "Winning Team: " << winner << endl;
cout << "Player Score" << endl << endl;
if(winner == "Blue") {
for(int x=0; x<3; x++) {
cout << blue_team[x] << setw(5) << blue_scores[x] << endl;
}
} else {
for(int y=0; y<3; y++) {
cout << white_team[y] << setw(5) << white_scores[y] << endl;
}
}
}
Revise this Paste