Question

Complete ACTIVITY program using the following specification: Write a C++ program that displays a suggested activity...

Complete ACTIVITY program using the following specification:
Write a C++ program that displays a suggested activity based on the outdoor temperature (in fahrenheit) and whether or not it is raining/snowing. Use the following table for suggested activities. Show both with nested loops and with logical operators.( WRITE THE CODE VERY CLEARY SHOWING ALL THE STEPS)

Temperature

Raining/Snowing

Activity

>=80

no

beach volleyball

>=80

yes

movie

<80 and >=32

no

running

<80 and >=32

yes

racquetball

<32

no

ice fishing

<32

yes

skiing

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Explanation:

temp variable stores the temperature in fahrenheit.

rain_or_snow stores yes or no (if it is raining/snowing or not)

while loop is used to take input again and again for rain_or_snow variable until user enters a "yes" or "no"

Then, if else if else blocks are used to check the values of temperature and inside the block, another if else blocks are there to check the value of rain_or_snow and print output accordingly.

Code:


#include <iostream>

using namespace std;

int main()
{
  
int temp;
cout<<"Enter the temperature in Fahrenheit: ";
cin>>temp;
  
string rain_or_snow;
cout<<"Is it raining or snowing? (yes/no): ";
cin>>rain_or_snow;
  
while(rain_or_snow!="yes" && rain_or_snow!="no")
{
cout<<"Please enter yes or no"<<endl;
cin>>rain_or_snow;
}
  
if(temp>=80)
{
if(rain_or_snow=="no")
cout<<"beach volleyball"<<endl;
else
cout<<"movie"<<endl;
}
else if(temp>=32)
{
if(rain_or_snow=="no")
cout<<"running"<<endl;
else
cout<<"racquetball"<<endl;
}
else
{
if(rain_or_snow=="no")
cout<<"ice fishing"<<endl;
else
cout<<"skiing"<<endl;
}
  

return 0;
}

Output:

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!

Add a comment
Know the answer?
Add Answer to:
Complete ACTIVITY program using the following specification: Write a C++ program that displays a suggested activity...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT