Question

Write a program that inputs Celsius temperatures (use a void function), converts them to Fahrenheit (f...

Write a program that inputs Celsius temperatures (use a void function), converts them to Fahrenheit (f = 9/5C + 32, use a value returning function) and prints whether it is a day for swimming or skiing (use a function). Include a loop in main that quits looping on -999.

code in C++

please include a screen shot of the code as it is easier to read

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

#include <iostream>
using namespace std;

// prototype declaration
void inputCelsiusTemp(double &celsius);// void function
double convertFahrenheit(double celsius); // returning value function

// MAIN FUNCTION
int main(){
double celsius; // declare variable
while(true){ // run infinite
        inputCelsiusTemp(celsius); // take input
       
       if(celsius==-999) // check if input is -999 stop and break
       break;
      
       double fahrenheit = convertFahrenheit(celsius); // calc temp in fahrenheit
       cout<<fahrenheit<<endl; // print fahrenheit
   
      if(fahrenheit < 78){ // check if < 78
            cout<<"Skiing day"<<endl;  
       }else{
           cout<<"Swimming day"<<endl;
       }
}
cout<<"Good Bye"<<endl; // print message
return 0;
}

// FUNCTION DEFINITION
// take input
void inputCelsiusTemp(double &celsius){
   cout<<"Enter temperature in celsius: ";
   cin >> celsius;
}
// convert and return
double convertFahrenheit(double celsius){
   double fahrenheit = (celsius * 9.0) / 5.0 + 32;
   return fahrenheit;
}

/* OUTPUT */

Enter temperature in celsius : 24 75.2 Skiing day Enter temperature in celsius : 26 78.8 Swimming day Enter temperature in ce

/* PLEASE UPVOTE */

Add a comment
Know the answer?
Add Answer to:
Write a program that inputs Celsius temperatures (use a void function), converts them to Fahrenheit (f...
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