Guest User

Untitled

a guest
Apr 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #include <fstream>
  4.  
  5. int day[365];
  6. double htemp[365];
  7. double ltemp[365];
  8. double windspeed[365];
  9. double humidity[365];
  10. void getinfo( int& ix, int& datatotal );
  11. void mainmenu( int datatotal, int ix );
  12. void menuselection ( int choice, int datatotal, int ix );
  13. void displaydata( int datatotal, int ix );
  14.  
  15. int main()
  16. {
  17. int datatotal;
  18. int ix = 0;
  19. cout << "Welcome to the Weather Station Program" << endl;
  20. cout << endl;
  21. getinfo( ix, datatotal );
  22. ix = 0;
  23. mainmenu( datatotal, ix );
  24.  
  25. return 0;
  26. }
  27. void getinfo( int& ix, int& datatotal )
  28. {
  29. char kord;
  30. do
  31. {
  32. cout << "Would you like to enter the data from the keyboard or a data file?" << endl;
  33. cout << "(enter k for keyboard or d for data file): ";
  34. cin >> kord;
  35. }
  36. while( kord != 'k' && kord != 'd' );
  37. if ( kord == 'd' )
  38. {
  39. cout << endl;
  40. cout << "Enter the path for the data file." << endl;
  41. cout << "(for example C:\\Temp\\weatherdata.txt): ";
  42. cout << endl;
  43. }
  44. else
  45. {
  46. cout << endl;
  47. cout << "Please enter the following data. When you are done entering the data," << endl;
  48. cout << "enter in 0 for the day entry" << endl;
  49. int ix = 0;
  50. do
  51. {
  52. cout << endl;
  53. cout << "Enter the Day number (maximum of 365): ";
  54. datatotal = ix;
  55. cin >> ix;
  56. day[ix] = ix;
  57. if( ix == 0 )
  58. {
  59. cout << endl;
  60. }
  61. else
  62. {
  63. cout << endl;
  64. cout << "Enter the High Temperature of the day: ";
  65. cin >> htemp[ix];
  66. cout << endl;
  67. cout << "Enter the Low Temperature of the day: ";
  68. cin >> ltemp[ix];
  69. cout << endl;
  70. cout << "Enter the High Windspeed of the day: ";
  71. cin >> windspeed[ix];
  72. cout << endl;
  73. cout << "Enter the Relative Humidity of the day (in percent): ";
  74. cin >> humidity[ix];
  75. cout << endl;
  76. ++ix;
  77. }
  78. }
  79. while( ix != 0 );
  80.  
  81. }
  82. }
  83. void mainmenu( int datatotal, int ix )
  84. {
  85. int choice;
  86. do
  87. {
  88. cout << endl;
  89. cout << "Please choose one of the following choices " << endl;
  90. cout << "(1) Display the data " << endl;
  91. cout << "(2) Display the maximun, minimum, and range of one field" << endl;
  92. cout << "(3) Display the largest difference between two consecutive" << endl;
  93. cout << "in one field" << endl;
  94. cout << "(4) Display a chart summarizing the distribution of the values" << endl;
  95. cout << "in one field" << endl;
  96. cout << "(5) Display the heat index for each day" << endl;
  97. cout << "(6) Stop Analyzing this collection of data" << endl;
  98. do
  99. {
  100. cout << "Enter a number from 1 to 6: ";
  101. cin >> choice;
  102. cout << endl;
  103. }
  104. while( choice > 6 || choice < 1 );
  105. if( choice >= 1 && choice <= 5 )
  106. {
  107. menuselection( choice, datatotal, ix );
  108. }
  109. else
  110. {
  111. cout << endl;
  112. cout << "Error" << endl;
  113.  
  114. }
  115. }
  116. while( choice != 6 );
  117. }
  118. void menuselection ( int choice, int datatotal, int ix )
  119. {
  120.  
  121. if( choice == 1 )
  122. {
  123. displaydata( datatotal, ix );
  124. }
  125. else if( choice == 2 )
  126. {
  127. cout << "test2" << endl;
  128. }
  129. else if( choice == 3 )
  130. {
  131. cout << "test3" << endl;
  132. }
  133. else if( choice == 4 )
  134. {
  135. cout << "test4" << endl;
  136. }
  137. else
  138. {
  139. cout << "test5" << endl;
  140. }
  141.  
  142. }
  143. void displaydata( int datatotal, int ix )
  144. {
  145. int counter, gateway;
  146. char yorn;
  147. cout << "Display data" << endl;
  148. cout << endl;
  149. for ( ix = 0; ix <= datatotal; ++ix )
  150. {
  151. counter = 1;
  152. do
  153. {
  154. if( day[ix] != 0 )
  155. {
  156. cout << day[ix] << " "
  157. << htemp[ix] << " "
  158. << ltemp[ix] << " "
  159. << windspeed[ix] << " "
  160. << humidity[ix] << endl;
  161. cout << endl;
  162. ++counter;
  163. }
  164. else
  165. {
  166. }
  167.  
  168. }
  169. while( counter <= 9 );
  170. cout << "Would you like to stream more data?" << endl;
  171. cout << "(y or n): ";
  172. cin >> yorn;
  173. if( yorn == 'y' )
  174. {
  175. }
  176. else
  177. {
  178. gateway = ix;
  179. ix = datatotal;
  180. }
  181. }
  182. ix = gateway;
  183. }
Add Comment
Please, Sign In to add comment