// Basically i need to make 3 functions // getTemps() // this function asks the
ID: 3648414 • Letter: #
Question
// Basically i need to make 3 functions// getTemps()
// this function asks the user to enter 3 temperatures for 3 cities.
// the numbers are read and assigned to variables
// the function is a void-returning function
// calcAvg()
// The function calculates the average temperature of the 3.
// the function is returned to main().
// displayAvg()
// the function displays the information on the screen
// output
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void getTemps();
double calcAvg(double, double, double, double);
void displayAvg(double);
int main ()
{
double temp1, temp2, temp3, total;
getTemps();
calcAvg();
displayAvg(total);
return 0;
}
void getTemps()
{
double temp1;
double temp2;
double temp3;
cout << "Enter the temperature of 3 cities: ";
cout << " #1: ";
cin >> temp1;
cout << " #2: ";
cin >> temp2;
cout << " #3: ";
cin >> temp3;
}
double calcAvg(double temp1, double temp2, double temp3, double total)
{
(total) = ((temp1 + temp2 + temp3) / (3));
return total;
}
void displayAvg(double total)
{
cout << "The average is: " << total;
}
Explanation / Answer
#include #include #include using namespace std; void getTemps(); double calcAvg(double, double, double, double); void displayAvg(double); double temp1, temp2, temp3, total; int main () { getTemps(); calcAvg(temp1,temp2,temp3); displayAvg(total); return 0; } void getTemps() { cout temp1; cout > temp2; cout > temp3; } double calcAvg() { (total) = ((temp1 + temp2 + temp3) / (3)); return total; } void displayAvg(double total) { coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.