Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct airStats {
  5.  
  6. int Landed;
  7. int Departed;
  8. int greatestLanded;
  9. int leastLanded;
  10.  
  11. };
  12.  
  13.  
  14. int main(){
  15. const int size = 12;
  16. airStats planes[size];
  17. int index;
  18.  
  19. cout << "Please enter the statistics when prompted.\n";
  20. cout << endl;
  21.  
  22. for (index = 0; index < size; index++)
  23. {
  24. cout << "Total number of planes landed in month #" << (index + 1);
  25. cout << ": ";
  26. cin >> planes[index].Landed;
  27.  
  28. cout << "Total number of planes departed in month #" << (index + 1);
  29. cout << ": ";
  30. cin >> planes[index].Departed;
  31.  
  32. cout << "Greatest number of planes that landed in a day in month #" << (index + 1);
  33. cout << ": ";
  34. cin >> planes[index].greatestLanded;
  35.  
  36. cout << "Least number of planes that landed in a day in month #" << (index + 1);
  37. cout << ": ";
  38. cin >> planes[index].leastLanded;
  39. cout << endl;
  40. }
  41.  
  42. int Lsum = 0;
  43. for(int index = 0; index < size; index++)
  44. {
  45. Lsum = Lsum + planes[index].Landed;
  46. }
  47. cout << "The total number of planes that landed this year is " << Lsum << endl;
  48.  
  49. int Dsum = 0;
  50. for(int index = 0; index < size; index++)
  51. {
  52. Dsum = Dsum + planes[index].Departed;
  53. }
  54. cout << "The total number of planes that departed this year is " << Dsum << endl;
  55.  
  56. int totalPlanes = Lsum + Dsum;
  57. cout << "The total number of planes that landed and departed this year is " << totalPlanes << endl;
  58. cout << endl;
  59.  
  60. double Laverage = Lsum / size;
  61. double Daverage = Dsum / size;
  62. cout << "The average number of planes that landed each month is " << Laverage << endl;
  63. cout << "The average number of planes that departed each month is " << Daverage << endl;
  64. cout << endl;
  65.  
  66.  
  67.  
  68. int highest;
  69. int lowest;
  70.  
  71. highest = planes[index].greatestLanded;
  72. for (index = 0; index < size; index++)
  73. {
  74. if (planes[index].greatestLanded > highest)
  75. highest = planes[index].greatestLanded;
  76. }
  77.  
  78. cout << "The greatest number of planes that landed in a single day this year is " << highest << endl;
  79.  
  80. lowest = planes[index].leastLanded;
  81. for (index = 0; index < size; index++)
  82. {
  83. if (planes[index].leastLanded < lowest)
  84. lowest = planes[index].leastLanded;
  85. }
  86.  
  87. cout << "The lowest number of planes that landed in a single day this year is " << lowest << endl;
  88. cout << endl;
  89.  
  90.  
  91.  
  92. for(index = 0; index < size; index++)
  93. {
  94. if(planes[index].greatestLanded == highest){
  95. cout << "The month that had the day with the most landed planes is month #" << index + 1 << endl;
  96. break;
  97. }
  98. }
  99.  
  100. for(index = 0; index < size; index++)
  101. {
  102. if(planes[index].leastLanded == lowest){
  103. cout << "The month that had the day with the least landed planes is month #" << index + 1 << endl;
  104. break;
  105. }
  106. }
  107.  
  108.  
  109.  
  110. return 0;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement