//Sam Trivikraman CS1A Chapter 11, p. 646, #6 // /* ****************************************************************************** Store Soccer Stats _______________________________________________________________________________ This program stores the player's name, number, and points scored for a soccer team. _______________________________________________________________________________ INPUT player name : The player's name player number : The player's number points scored : The number of points the player scored OUTPUT array of player stats : An array that stores all of the details for the players on the team _______________________________________________________________________________ ******************************************************************************* */ #include <iostream> using namespace std; //a struct that stores all of the player's details struct player { string name; //INPUT The player's name int num; //INPUT The player's number int points; //INPUT The number of points the player scored }; int main() { player team[12]; //OUTPUT An array that stores all of the details for the players on the team //ask the user for the player's details for(int i = 0; i < 12; i++) { cout << "Please enter the player's name" << endl; cin >> team[i].name; cout << "Please enter the player's number" << endl; cin >> team[i].num; cout << "Please enter the number of points scored by this player" << endl; cin >> team[i].points; } //output the player's details for(int i = 0; i < 12; i++) { cout << "Player " << i << endl; cout << "Name: " << team[i].name << endl; cout << "Number: " << team[i].num << endl; cout << "Points: " << team[i].points << endl; } return 0; }
sally 1 20 bob 2 30 gin 3 20 you 4 20 me 5 80 funsies 6 230 weee 7 290 yes 8 90 no 9 120 mo 10 30 akana 11 304 annie 12 390
Please enter the player's name Please enter the player's number Please enter the number of points scored by this player Please enter the player's name Please enter the player's number Please enter the number of points scored by this player Please enter the player's name Please enter the player's number Please enter the number of points scored by this player Please enter the player's name Please enter the player's number Please enter the number of points scored by this player Please enter the player's name Please enter the player's number Please enter the number of points scored by this player Please enter the player's name Please enter the player's number Please enter the number of points scored by this player Please enter the player's name Please enter the player's number Please enter the number of points scored by this player Please enter the player's name Please enter the player's number Please enter the number of points scored by this player Please enter the player's name Please enter the player's number Please enter the number of points scored by this player Please enter the player's name Please enter the player's number Please enter the number of points scored by this player Please enter the player's name Please enter the player's number Please enter the number of points scored by this player Please enter the player's name Please enter the player's number Please enter the number of points scored by this player Player 0 Name: sally Number: 1 Points: 20 Player 1 Name: bob Number: 2 Points: 30 Player 2 Name: gin Number: 3 Points: 20 Player 3 Name: you Number: 4 Points: 20 Player 4 Name: me Number: 5 Points: 80 Player 5 Name: funsies Number: 6 Points: 230 Player 6 Name: weee Number: 7 Points: 290 Player 7 Name: yes Number: 8 Points: 90 Player 8 Name: no Number: 9 Points: 120 Player 9 Name: mo Number: 10 Points: 30 Player 10 Name: akana Number: 11 Points: 304 Player 11 Name: annie Number: 12 Points: 390