C++ optional exercise.
You are going to convert temperatures in this program. You will give the user the choice of converting Fahrenheit to Celsius or Celsius to Fahrenheit. With the correct answer you will also display the number entered. The user should have the option to convert as many temperatures as they want. Use functions and a menu (also a function) and, assume they will convert at least one temperature. When finished upload and submit the zipped project.
the formulas are:
centigrade = (fahrenheit - 32) * 5/9
fahrenheit = centigrade * 9/5 + 32
Trivia: the brains behind:
Anders Celsius, Swedish physicist and astronomer, 1701 -
1744
Gabriel Fahrenheit, German physicist, 1686 - 1736, inventor of the
thermometer
how did they choose the ranges?
CELSIUS:
range of 100 steps,
0 degree Centigrade = freezing point of water,
100 degree Centigrade = boiling point of water
FAHRENHEIT:
range of 180 steps,
32 degree Fahrenheit = freezing point of water,
100 degree Fahrenheit = body temperature of a person (not very
accurate...),
212 degree Fahrenheit = boiling point of water
Hello, here is the completed code you wanted. Every important statement is explained using comments. Please check and let me know if you have any doubts. Thanks.
CODE
#include<iostream>
using namespace std;
//menu function
int menu()
{
int choice;
cout<<"1. Fahrenheit to
Celsius"<<endl;
cout<<"2. Celsius to
Fahrenheit"<<endl;
cout<<"3. Quit"<<endl;
cin>>choice;
return choice;
}
//Fahrenheit to Celsius function
void Fahrenheit_Celsius()
{
//variable decleration
float
temperature_celsius,temperature_fahrenheit;
//prompt for temperature in Fahrenheit
cout<<"Enter the temperature in Fahrenheit:
";
//inputs temperature in Fahrenheit
cin>>temperature_fahrenheit;
//calculating temperature in Celsius
temperature_celsius=(temperature_fahrenheit-32)*(float(5)/float(9));
//printing output
cout<<"Temperature in Fahrenheit:
"<<temperature_fahrenheit<<" Temperature in Celsius:
"<<temperature_celsius<<endl;
}
//Celsius to Fahrenheit
void Celsius_Fahrenheit()
{
//variable decleration
float
temperature_celsius,temperature_fahrenheit;
//prompt for temperature in Celsius
cout<<"Enter the temperature in celsius:
";
//inputs temperature in Celsius
cin>>temperature_celsius;
//calculating temperature in Fahrenheit
temperature_fahrenheit=(temperature_celsius*(float(9)/float(5)))+32;
//printing output
cout<<"Temperature in Celsius:
"<<temperature_celsius<<" Temperature in Fahrenheit:
"<<temperature_fahrenheit<<endl;
}
int main()
{
int choice;
while(true)
{
//calling menu function
choice=menu();
//if choice is 1
if(choice==1)
{
//calling
Fahrenheit to Celsius function
Fahrenheit_Celsius();
}
//if choice is 2
else if(choice==2)
{
//calling
Celsius to Fahrenheit function
Celsius_Fahrenheit();
}
//if choice is 3
else if(choice==3)
{
//exiting from
program
break;
}
//if choice is wrong
else
{
cout<<"Wrong choice! Try again...."<<endl;
}
}
return 0;
}
OUTPUT
CODE SCREEN SHOT
C++ optional exercise. You are going to convert temperatures in this program. You will give the...
This program will take the user's input as a temperature in degrees Fahrenheit. The user will then click a radio button indicating whether a table of temperatures, starting with the entered value, will be displayed in increments of 5 degrees F or 10 degrees F. When a submit button is clicked your code will display a HTML table of temperature values. The first column will be temperatures in degrees Fahrenheit, given in increments of 5 or 10 degrees F, depending...
Lab Manual 12 Temperature There are two temperature scales: the Fahrenbeit (F) and Celsius (centigrade, C) scales (Fig. 2.5). Scientists ase the Celsius scale. 230 1. Stady the two scales in Figure 2.5, and complete the following information Experimental Procedure: Temperature 220 s30-100 Boiling 200 F - a Water freezes at 190 C. "F 180 2 To convert from the Fahrenheit to the Celsius scale, use the following equation b Water boils at 170 160 150 C-CF-32VL8 140 F-(18C) +32...
You can vary it as long as the fahr and cels temperatures line up vertically and everything is clearly labeled. This program involves inputting a set of Fahrenheit temperatures and performing a set of operations on them: The number of temperatures to input is determined by the user at the beginning of the program. You must ask them to enter the number of temperatures that they will be typing in. This number must be between 1 and 30 (inclusive.) If...
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...
36. A. What is the difference between intensive and extensive properties? (Circle one correct answer) a) An intensive property is independent of the amount of the substance, whereas extensive property depends on b) Along with the change of the amount of substance, an intensive property changes faster than extensive property. c) Intensive properties are quantitative properties of substance, while extensive properties are qualitative d) An extensive property is independent of the amount of the substance, whereas intensive property depends on...
package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task #1 before adding Task#2 where indicated. */ public class NumericTypesOriginal { public static void main (String [] args) { //TASK #2 Create a Scanner object here //identifier declarations final int NUMBER = 2 ; // number of scores int score1 = 100; // first test score int score2 = 95; // second test score final int BOILING_IN_F = 212; // boiling temperature double fToC;...