Advertisement
Guest User

5.2

a guest
Nov 17th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. double TData[2][7];
  4.  
  5.  
  6.  
  7.  
  8. void getData(){
  9. cout<<"Please input the highest temperature of every day respectively this week."<<endl;
  10. for(int i=0;i<7;++i){
  11. cin>>TData[0][i];
  12. }
  13. cout<<"Please input the lowest temperature of every day respectively this week."<<endl;
  14. for(int i=0;i<7;++i){
  15. cin>>TData[1][i];
  16. }
  17. }
  18.  
  19.  
  20.  
  21.  
  22. void averageHigh(){
  23. double avgHigh=0;
  24. for(int i=0;i<7;++i){
  25. avgHigh+= TData[0][i];
  26. }
  27. avgHigh=avgHigh/7.0;
  28. cout<<"The average high temperature this week is: "<<avgHigh<<endl;
  29. }
  30.  
  31.  
  32.  
  33.  
  34. void averageLow(){
  35. double avgLow=0;
  36. for(int i=0;i<7;++i){
  37. avgLow+= TData[1][i];
  38. }
  39. avgLow=avgLow/7.0;
  40. cout<<"The average low temperature this week is: "<<avgLow<<endl;
  41. }
  42.  
  43.  
  44.  
  45.  
  46. void indexHighTemp(){
  47. double highT=0.0;
  48. for(int i=0;i<7;++i){
  49. if(highT<TData[0][i]){
  50. highT=TData[0][i];
  51. }
  52. }
  53.  
  54. cout<<"The highest temperate this week is: "<<highT<<endl;
  55. }
  56.  
  57.  
  58.  
  59.  
  60. void indexLowTemp(){
  61. double LowT=0.0;
  62. for(int i=0;i<7;++i){
  63. if(LowT>TData[1][i]){
  64. LowT=TData[1][i];
  65. }
  66. }
  67.  
  68. cout<<"The lowest temperate this week is: "<<LowT<<endl;
  69. }
  70. int main()
  71. {
  72. getData();
  73. averageHigh();
  74. averageLow();
  75. indexHighTemp();
  76. indexLowTemp();
  77.  
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement