Assume there is an int variable called temp. Write [only] a decision structure t
ID: 3666639 • Letter: A
Question
Assume there is an int variable called temp.
Write [only] a decision structure that allows the classification of weather temperatures in fahrenheit.
Freezing: 32 degrees and lower
Cold: above freezing up to 55 degrees
Cool: above cold up to 70 degrees
Mild: above cool up to 80 degrees
Warm: above mild up to 80 degrees
Hot: above warm
HInt: It is best to use an if-else-if structure.
#include<iostream>
using namespace std;
int main()
{
int temp = 0;
cout << "Enter temperature reading in fahrenheit (without the text or symbol for degrees): ";
cin >> temp;
cout << temp <<" degrees F is considered as ";
/* Your code here */
return 0;
}
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
int temp = 0;
cout << "Enter temperature reading in fahrenheit (without the text or symbol for degrees): ";
cin >> temp;
cout << temp <<" degrees F is considered as ";
if(temp <= 32){
cout << "Freezing ";
}else if(temp <= 55){
cout << " cold";
}else if(temp <= 70){
cout << "cool";
}else if(temp <= 80){
cout << "warm";
}else{
cout <<"hot";
}
return 0;
}
Let me know if I have to conver F to degree den answer.