Advertisement
efeertas

touchdown

Mar 26th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.00 KB | None | 0 0
  1. #include <iostream>
  2.     #include <iomanip>
  3.     #include <string>
  4.     using namespace std;
  5.     const int SIZE = 50;
  6.     int Totalcatches(int *, int);
  7.     struct Player
  8.     {
  9.            char name[SIZE];
  10.            int position;
  11.            int catches;
  12.            int touchdowns;
  13.            int passing_yards;
  14.            int receiving_yards;
  15.            int rushing_yards;
  16.     };
  17.  
  18.  
  19.     int main()
  20.     {
  21.         const int NUM_PLAYERS = 12;
  22.         Player *players = new Player[NUM_PLAYERS];
  23.         int index;
  24.        int total=0;
  25.  
  26.         cout << "Please enter the required info below.\n";
  27.         cout << "The Player's Names, Player's Numbers\n";
  28.        cout << "Finally you will need the catches Scored by Players.\n\n\n";
  29.        cout << "Number of touchdowns\n";
  30.        cout << "Number of passing yards\n";
  31.        cout << "Number of receiving yards\n";
  32.  
  33.        cout << "The Player's Names, Player's Numbers\n";
  34.         for (index = 0; index < NUM_PLAYERS; index++)
  35.         {
  36.             cout << "Please enter the Player's Name: ";
  37.            cin.getline( players[index].name, 50 );
  38.             cout << "Please enter the Player's Number: ";
  39.             ( cin >> players[index].position ).get();
  40.  
  41.            while (players[index].position <=0)
  42.            {
  43.                cout << "Zero or negative numbers not allowed\n";
  44.                cout << "Please enter the Player's Number: ";
  45.                (cin >> players[index].position).get();
  46.            }
  47.             cout << "Please enter the catches Scored by the Player: ";
  48.             ( cin >> players[index].catches ).get();
  49.  
  50.            while (players[index].catches < 0)
  51.            {
  52.                cout << "Zero or negative numbers not allowed\n";
  53.                cout << "Please enter the catches Scored by the Player: ";
  54.                (cin >> players[index].catches).get();
  55.            }
  56.  
  57.            cout << "Please enter the touchdowns: ";
  58.                     ( cin >> players[index].touchdowns ).get();
  59.  
  60.                    while (players[index].touchdowns < 0)
  61.                    {
  62.                        cout << "Zero or negative numbers not allowed\n";
  63.                        cout << "Please enter the touchdowns by the Player: ";
  64.                        (cin >> players[index].touchdowns).get();
  65.            }
  66.  
  67.            cout << "Please enter the passing yards: ";
  68.                             ( cin >> players[index].passing_yards).get();
  69.  
  70.                            while (players[index].passing_yards < 0)
  71.                            {
  72.                                cout << "Zero or negative numbers not allowed\n";
  73.                                cout << "Please enter the passing yards by the Player: ";
  74.                                (cin >> players[index].passing_yards).get();
  75.            }
  76.  
  77.            cout << "Please enter the receiving yards: ";
  78.                             ( cin >> players[index].receiving_yards).get();
  79.  
  80.                            while (players[index].receiving_yards < 0)
  81.                            {
  82.                                cout << "Zero or negative numbers not allowed\n";
  83.                                cout << "Please enter the touchdowns by the Player: ";
  84.                                (cin >> players[index].receiving_yards).get();
  85.            }
  86.  
  87.            cout << "Please enter the rushing yards";
  88.                                     ( cin >> players[index].rushing_yards).get();
  89.  
  90.                                    while (players[index].rushing_yards < 0)
  91.                                    {
  92.                                        cout << "Zero or negative numbers not allowed\n";
  93.                                        (cin >> players[index].rushing_yards).get();
  94.            }
  95.            cout << endl << endl;
  96.         }
  97.  
  98.        cout << "Here is the players data:\n\n";
  99.        cout << "    Name    Number    Score   \n";
  100.        cout << "--------------------------------\n";
  101.        for (index = 0; index < NUM_PLAYERS; index++)
  102.        {
  103.            cout << setw(8) << players[index].name;
  104.            cout << setw(8) << players[index].position;
  105.            cout << setw(8) << players[index].catches << endl;
  106.            cout << setw(8) << players[index].touchdowns << endl;
  107.            cout << setw(8) << players[index].passing_yards << endl;
  108.            cout << setw(8) << players[index].receiving_yards << endl;
  109.  
  110.        }
  111.  
  112.        for (index = 0; index < NUM_PLAYERS; index++)
  113.        {
  114.            total += players[index].catches;
  115.  
  116.        }
  117.  
  118.        cout << "\n\nThe total of points scored by the team are: ";
  119.        cout << total << endl;
  120.  
  121.  
  122.        int max = players[0].catches;
  123.         int maxIndex = 0;
  124.         for (int index = 0; index < 12; index++)
  125.         {
  126.            if (players[index].catches > max)
  127.           {
  128.               max = players[index].catches;
  129.               maxIndex = index;
  130.           }
  131.         }
  132.  
  133.        cout << "highest score by: <" << players[maxIndex].name << "> number: " << players[maxIndex].position << endl;
  134.  
  135.         cin.get();
  136.  
  137.  
  138.  
  139.         return 0;
  140.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement