Question
Revise the program so that it contains the functions listed as follows. You must follow the specifications for each function exactly. getTemps - This function
Revise the program so that it contains the functions listed as follows. You must follow the specifications for each function exactly.
-
getTemps - This function will get four temperatures from the user. The function must be a void function and all parameters must be appropriate.
-
calculateTotalAve - This function will calculate the total and average of the temperatures. The function must be a void function and all parameters must be appropriate.
-
calculateLowTemp - This function will calculate the lowest temperatur. This function must be a value returning function and all parameters must be appropriate.
-
display - This function will display the temperatures, total temperature, average temperature and lowest temperature. This function must be a void function and all parameters must be appropriate.
My code so far:
// This program will calculate the lowest and average temperatures based on user input. #include
void getTemps(int temp1, int temp2, int temp3, int temp4); //Function to get temperatures.
int main() { int temp1, temp2, temp3, temp4, totalTemp, lowTemp; double averageTemp;
getTemps(temp1, temp2, temp3, temp4); //Function Call
cout << "Enter the first temperature : "; cin >> temp1; cout << "Enter the second temperature : "; cin >> temp2; cout << "Enter the third temperature : "; cin >> temp3; cout << "Enter the fourth temperature : "; cin >> temp4;
system ("pause"); return 0; }
void calculateTotalAve(int temp1, int temp2, int temp3, int temp4, int averageTemp, int totalTemp); //Function to calculate the total average temperature { totalTemp = temp1 + temp2 + temp3 + temp4; averageTemp = totalTemp / 4.0; }
int calculateLowTemp(int temp1, int temp2, int temp3, int temp4); { if (temp1 <= temp2 && temp1 <= temp3 && temp1 <= temp4) lowTemp = temp1; else if (temp2 <= temp1 && temp2 <= temp3 && temp2 <= temp4) lowTemp = temp2; else if (temp3 <= temp1 && temp3 <= temp2 && temp3 <= temp4) lowTemp = temp3; else lowTemp = temp4; system ("pause"); return 0; }
cout << fixed << setprecision(1); cout << endl << "Temperatures:" << endl; cout << temp1 << endl << temp2 << endl << temp3 << endl << temp4 << endl; cout << "Temperature total : " << totalTemp << endl << "Temperature average : " << averageTemp << endl << "Lowest temperature : " << lowTemp << endl;
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started