fork download
  1. //Sam Trivikraman CS1A Chapter 11, p. 646, #6
  2. //
  3. /*
  4.  ******************************************************************************
  5. Store Soccer Stats
  6. _______________________________________________________________________________
  7. This program stores the player's name, number, and points scored for a soccer
  8. team.
  9. _______________________________________________________________________________
  10. INPUT
  11. player name : The player's name
  12. player number : The player's number
  13. points scored : The number of points the player scored
  14.  
  15. OUTPUT
  16. array of player stats : An array that stores all of the details for the players on the team
  17. _______________________________________________________________________________
  18. *******************************************************************************
  19. */
  20.  
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. //a struct that stores all of the player's details
  25. struct player
  26. {
  27.  
  28. string name; //INPUT The player's name
  29. int num; //INPUT The player's number
  30. int points; //INPUT The number of points the player scored
  31.  
  32. };
  33.  
  34. int main() {
  35.  
  36. player team[12]; //OUTPUT An array that stores all of the details for the players on the team
  37.  
  38. //ask the user for the player's details
  39. for(int i = 0; i < 12; i++)
  40. {
  41. cout << "Please enter the player's name" << endl;
  42. cin >> team[i].name;
  43. cout << "Please enter the player's number" << endl;
  44. cin >> team[i].num;
  45. cout << "Please enter the number of points scored by this player" << endl;
  46. cin >> team[i].points;
  47. }
  48.  
  49. //output the player's details
  50. for(int i = 0; i < 12; i++)
  51. {
  52. cout << "Player " << i << endl;
  53. cout << "Name: " << team[i].name << endl;
  54. cout << "Number: " << team[i].num << endl;
  55. cout << "Points: " << team[i].points << endl;
  56. }
  57. return 0;
  58. }
Success #stdin #stdout 0.01s 5280KB
stdin
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
stdout
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