Answer to Question #176190 in C++ for meng

Question #176190

Develop a solution that will calculate the average temperature, given a set of temperatures. The number of temperatures may differ from time to time. (Use a trip values to stop the processing of the loop.) Test the solution with the following 10 temperatures.

 

78  90

85  80

87   83

75  90

86  70


1
Expert's answer
2021-03-27T10:17:20-0400
#include <iostream>
 
using namespace std;
 
int main()
{
	double currentTemp = 0;
	double sumOfTemps = 0;
	double averageTemp = 0;
	int numberOfTemp = 0;
	cout << "Enter number of temperatures: ";
	cin >> numberOfTemp;
	cout << "Enter set of temperatures using space to separate values." << endl;
 
	for (int i = 0; i < numberOfTemp; i++)
	{
		cin >> currentTemp;
		sumOfTemps += currentTemp;
	}
	averageTemp = sumOfTemps / numberOfTemp;
	cout << "Average temperature for this set is: " << averageTemp << endl << endl;
	
 
	return 0;
}

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