Answer to Question #229909 in C++ for Haf

Question #229909
The weather service center of a certain city records the highest temperature, lowest temperature, and humidity of each day. Write a program that maintains three arrays and initializes the highest temperature, lowest temperature, and humidity in the three arrays, for each day of the first 10 days of a month. The program should then create a weather report that includes the following information:
Highest temperature and lowest temperature.
Diurnal variation in each day.
Humidity of each day and whether it is greater or less than the average humidity.
Finally, in an end note, it should display the maximum temperature, minimum temperature, and overall variation in temperature in the duration.
1
Expert's answer
2021-08-26T18:47:09-0400
 #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n =10;
	int highestTemperature [n];
	int lowestTemperature [n];
	double humidity [n];
	double totalHumidity = 0.0;
	cout<<"Enter the details as prompted\n";
	for(int i=0; i<n; i++){
		cout<<"Enter the highest temperature for day "<<(i+1)<<endl;
		cin>>highestTemperature [i];
		cout<<"Enter the lowest temperature for day "<<(i+1)<<endl;
		cin>>lowestTemperature  [i];
		cout<<"Enter the humidity for day "<<(i+1)<<endl;
		cin>>humidity[i];
		totalHumidity += humidity[i];
	}
	double average = totalHumidity / n;
	cout<<"The total humidity is  "<<totalHumidity<<"  .The average humidity is  "<<average<<endl;
	int diurnalVariation [n];
		for(int i=0; i<n; i++){
			diurnalVariation [i] = highestTemperature [i] - lowestTemperature [i];
		}
		for(int i=0; i<n; i++){
		cout<<diurnalVariation [i]<<endl;
			
		}
		cout<<"\t\t\t\tWeather Report\t\t\t"<<endl;
cout<<"Day\tHighest Temperature\t"<<"Lowest Temperature\t"<<"Diurnal Variation\t"<<"Humidity\t"<<"Humidity Strength\n";
         for(int i = 0; i<n; i++){
         cout<<(i +1)<<"\t\t"<<highestTemperature [i]<<"\t\t\t"<<lowestTemperature [i]<<"\t\t\t";
         cout<<diurnalVariation [i]<<"\t\t"<<humidity[i]<<"\t\t\t";
         if(humidity[i]>average){
         	cout<<"Greater"<<endl;
		 }
		 else{
		 	cout<<"Less"<<endl;
		 }
         
         
		 }
 cout << "\nMaximum Temperature = "
         << *max_element(highestTemperature , highestTemperature  + n);
          cout << "\nMinimum Temperature = "
         << *min_element(highestTemperature, highestTemperature + n);
    cout<<"The overall humidity is\t"<<*max_element(humidity, humidity + n);
         
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS