Write a function printTemp that prints a message describing

Write a function printTemp() that prints a message describing a temperature value passed to the function as a float parameter. The following table describes the messages associated with different temperature ranges, t:

Solution

Temp.cpp

#include <iostream>

using namespace std;
void printTemp(float t);
int main()
{
printTemp(22.0);
printTemp(-22.0);
printTemp(64.0);

return 0;
}

void printTemp(float t)
{
if( t <= 0.0){
cout<<\"Freezing\"<<endl;
}
else if(t > 0.0 && t <= 20.0){
cout<<\"Cold\"<<endl;
}
else if(t > 20.0 && t <= 25.0){
cout<<\"Pleasant\"<<endl;
}
else if(t > 25.0 && t <= 32.0){
cout<<\"Warm\"<<endl;
}
else{
cout<<\"Hot\"<<endl;
}
}

Output:

Pleasant                                                                                                                                                                                                                    

Freezing                                                                                                                                                                                                                    

Hot

 Write a function printTemp() that prints a message describing a temperature value passed to the function as a float parameter. The following table describes th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site