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
  • In Python, write a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is as...

    In Python, write a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is as follows: F=(9/5)C+32 The program should ask the user to enter a temperature in Celsius, then display the temperature converted to Fahrenheit.

  • Write a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is as follows: F=95C+32...

    Write a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is as follows: F=95C+32 The program should ask the user to enter a temperature in Celsius, and then display the temperature converted to Fahrenheit. I'm doing this on Python.

  • (in python) Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user s......

    (in python) Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user s... Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, and then see the equivalent Fahrenheit temperature. Use the following formula to make the conversion ( F=9/5 C + 32) where F is the Fahrenheit temperature and C is the Celsius temperature

  • Write a Java program that converts Centigrade temperatures to Fahrenheit temperatures. The formula is F =...

    Write a Java program that converts Centigrade temperatures to Fahrenheit temperatures. The formula is F = 9/5C + 32 F is the Fahrenheit temperature and C is the centigrade temperature.

  • IN JAVA…Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be...

    IN JAVA…Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, and then see the equiva-lent Fahrenheit temperature. Use the following formula to make the conversion: F = (9/5)C + 32 F is the Fahrenheit temperature and C is the Celsius temperature. Instead of only converting from Celsius to Fahrenheit, also convert from Fahrenheit to Celsius depending on the user's choice. Some hints: Use JTextField and...

  • For this assignment you will create a program converting Fahrenheit temperatures to Celsius temperatures. The formula...

    For this assignment you will create a program converting Fahrenheit temperatures to Celsius temperatures. The formula for converting a temperature from Celsius to Fahrenheit is: F = C x 1.8 + 32, where F is the Fahrenheit temperature and C is the Celsius temperature. Write a function named Fahrenheit that accepts a Celsius temperature as an argument and returns the temperature converted to Fahrenheit. Demonstrate the function by accepting a Celsius temperature from a user and displaying the temperature converted...

  • Write a program named FahrenheitToCelsius that accepts a temperature in Fahrenheit from a user and converts...

    Write a program named FahrenheitToCelsius that accepts a temperature in Fahrenheit from a user and converts it to Celsius by subtracting 32 from the Fahrenheit value and multiplying the result by 5/9. Display both values to one decimal place. For example, if 88.5 degrees is input, the output would be: 88.5 F is 31.4 C Answer in C# (Posting incomplete code i have so far that wont run correctly.) using System; using static System.Console; class FahrenheitToCelsius { static void Main()...

  • Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The...

    Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a value-returning...

  • FOR PYTHON Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice...

    FOR PYTHON Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom functionc_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a...

  • General overview This program will convert a set of temperatures from Fahrenheit to Celsius and Kelvin....

    General overview This program will convert a set of temperatures from Fahrenheit to Celsius and Kelvin. Your program will be reading in three double values. The first values are starting and ending temperatures. The third value is the increment value. There is no prompt for the input. There is an error message that can be displayed. This is discussed later. You need to display output for all of the values between the starting and ending values. First two values are...

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