Question: Lab 3 - Calculations Instructions: Complete each problem. If you're struggling with a problem, feel free to ask questions on the class forum. This lab
Lab Calculations
Instructions: Complete each problem. If you're struggling with a problem, feel free to ask questions on the class forum.
This lab is optional, but it gives you valuable programming experience. You should definitely complete the lab if you can.
Problem Basic Calculations
Write a Console application to convert a temperature from Fahrenheit to Celsius and back again to verify the math!
Hint: What data type should you use to store the degrees? Your answer may have a dramatic affect on the outcome of your calculations
You need to use three variables for this program: one variable for the original temperature in Fahrenheit, one variable for the calculated temperature in Celsius, and one variable for the calculated temperature in Fahrenheit when you convert from Celsius back to Fahrenheit Be sure to name your variables appropriately.
To get the original temperature in Fahrenheit from the User:
Assuming you declared your first variable as a float named originalFahrenheit, here's the code you'd use to get the original temperature from the user:
Console.WriteEnter temperature Fahrenheit: ;
originalFahrenheit float.ParseConsoleReadLine;
The console ReadLine method returns whatever string the user typed on the keyboard before pressing the Enter key. Passing that string as an argument to the float Parse method converts the string to a float.
To go from Fahrenheit to Celsius:
Begin by subtracting from the Fahrenheit number.
Divide the answer by
Then multiply that answer by
For example, if it's degrees F outside, and you want to know the temperature in C :
To go from Celsius to Fahrenheit:
Begin by multiplying the Celsius temperature by
Divide the answer by
Now add
Display the following message:
XX degrees Fahrenheit is YY degrees Celsius
YY degrees Celsius is ZZ degrees Fahrenheit
XX should be a number that you assign to your first variable the one that holds the original temperature in Fahrenheit You must calculate YY the calculated temperature in Celsius from XX and you must calculate ZZ the calculated temperature in Fahrenheit from YY DO NOT use XX YY or ZZ in your code, these are just names I used as an example in the output.
Test your application with the following values for degrees Fahrenheit:
Note
You may discover that the conversion from to Celsius and back to Fahrenheit yields a very small, but nonzero, number. That's one of the points of this lab! Think about the data types you used and why you might get this result given those data types.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
