Advertisement
Guest User

football.cpp

a guest
May 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. struct stats
  6. {int touchdowns;
  7. int max;
  8. int min;
  9. double mode;
  10. double mode_freq;
  11. double mean;
  12. double total;
  13. }
  14. ;
  15.  
  16. int main()
  17. {
  18. int years;
  19. double count=0;
  20. stats player;
  21. cout<<"enter the touchdowns made each yeaar\n";
  22. cout<<"how many years do you want to put in?\n";
  23.     cin>>years;
  24.     stats scored[years];
  25. int index;
  26. player.max=0;
  27. player.mean=0;
  28. player.mode=0;
  29. player.mode_freq=1;
  30.     for (index = 0; index < years; index++)
  31. {
  32. cout << "enter the amount of touchdowns one year" << endl;
  33. cin >> scored[index].touchdowns;
  34. player.total=player.total+scored[index].touchdowns;
  35. if (player.min>scored[index].touchdowns)
  36. { player.min=scored[index].touchdowns;
  37. }
  38. if (scored[index].touchdowns>player.max)
  39. { player.max=scored[index].touchdowns;
  40. }
  41. }
  42.  
  43. do
  44. {
  45.     int j=index;
  46.     index++;
  47.     do
  48.     {
  49.         if(scored[index].touchdowns==scored[j].touchdowns)
  50.     {count=count+1;
  51.     }
  52. if (count>player.mode)
  53. {
  54.     player.mode=scored[index].touchdowns;
  55. }
  56. if (count>player.mode_freq)
  57. {
  58.     player.mode_freq=count;
  59. }
  60. j++;
  61. count=0;
  62.     }
  63.     while(j<years);
  64.  
  65.  
  66. }
  67. while (index<years);
  68.  
  69.  
  70. player.mean=player.total/years;
  71.     cout<<"touchdowns: "<<player.total<<endl;
  72.     cout<<"the min: "<<player.min<<endl;
  73.     cout<<"the max: "<<player.max<<endl;
  74.     cout<<"the mode: "<<player.mode<<endl;
  75.     cout<<"the mode freq.:"<<player.mode_freq<<endl;
  76.     cout<<"the mean: "<<player.mean<<endl;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement