Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- using namespace std;
- const int SIZE = 50;
- int Totalcatches(int *, int);
- struct Player
- {
- char name[SIZE];
- int position;
- int catches;
- int touchdowns;
- int passing_yards;
- int receiving_yards;
- int rushing_yards;
- };
- int main()
- {
- const int NUM_PLAYERS = 12;
- Player *players = new Player[NUM_PLAYERS];
- int index;
- int total=0;
- cout << "Please enter the required info below.\n";
- cout << "The Player's Names, Player's Numbers\n";
- cout << "Finally you will need the catches Scored by Players.\n\n\n";
- cout << "Number of touchdowns\n";
- cout << "Number of passing yards\n";
- cout << "Number of receiving yards\n";
- cout << "The Player's Names, Player's Numbers\n";
- for (index = 0; index < NUM_PLAYERS; index++)
- {
- cout << "Please enter the Player's Name: ";
- cin.getline( players[index].name, 50 );
- cout << "Please enter the Player's Number: ";
- ( cin >> players[index].position ).get();
- while (players[index].position <=0)
- {
- cout << "Zero or negative numbers not allowed\n";
- cout << "Please enter the Player's Number: ";
- (cin >> players[index].position).get();
- }
- cout << "Please enter the catches Scored by the Player: ";
- ( cin >> players[index].catches ).get();
- while (players[index].catches < 0)
- {
- cout << "Zero or negative numbers not allowed\n";
- cout << "Please enter the catches Scored by the Player: ";
- (cin >> players[index].catches).get();
- }
- cout << "Please enter the touchdowns: ";
- ( cin >> players[index].touchdowns ).get();
- while (players[index].touchdowns < 0)
- {
- cout << "Zero or negative numbers not allowed\n";
- cout << "Please enter the touchdowns by the Player: ";
- (cin >> players[index].touchdowns).get();
- }
- cout << "Please enter the passing yards: ";
- ( cin >> players[index].passing_yards).get();
- while (players[index].passing_yards < 0)
- {
- cout << "Zero or negative numbers not allowed\n";
- cout << "Please enter the passing yards by the Player: ";
- (cin >> players[index].passing_yards).get();
- }
- cout << "Please enter the receiving yards: ";
- ( cin >> players[index].receiving_yards).get();
- while (players[index].receiving_yards < 0)
- {
- cout << "Zero or negative numbers not allowed\n";
- cout << "Please enter the touchdowns by the Player: ";
- (cin >> players[index].receiving_yards).get();
- }
- cout << "Please enter the rushing yards";
- ( cin >> players[index].rushing_yards).get();
- while (players[index].rushing_yards < 0)
- {
- cout << "Zero or negative numbers not allowed\n";
- (cin >> players[index].rushing_yards).get();
- }
- cout << endl << endl;
- }
- cout << "Here is the players data:\n\n";
- cout << " Name Number Score \n";
- cout << "--------------------------------\n";
- for (index = 0; index < NUM_PLAYERS; index++)
- {
- cout << setw(8) << players[index].name;
- cout << setw(8) << players[index].position;
- cout << setw(8) << players[index].catches << endl;
- cout << setw(8) << players[index].touchdowns << endl;
- cout << setw(8) << players[index].passing_yards << endl;
- cout << setw(8) << players[index].receiving_yards << endl;
- }
- for (index = 0; index < NUM_PLAYERS; index++)
- {
- total += players[index].catches;
- }
- cout << "\n\nThe total of points scored by the team are: ";
- cout << total << endl;
- int max = players[0].catches;
- int maxIndex = 0;
- for (int index = 0; index < 12; index++)
- {
- if (players[index].catches > max)
- {
- max = players[index].catches;
- maxIndex = index;
- }
- }
- cout << "highest score by: <" << players[maxIndex].name << "> number: " << players[maxIndex].position << endl;
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement