Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C. Exercise: Temperature Conversion (10 points) Switch roles (the driver becomes the observer and the observer becomes the driver). Write a program that can convert
C. Exercise: Temperature Conversion (10 points) Switch roles (the driver becomes the observer and the observer becomes the driver). Write a program that can convert a temperature in degrees Kelvin to degrees Fahrenheit. The user should be prompted to enter the temperature in degrees Kelvin and the program should print on the screen the temperature in degrees Fahrenheit. In 1708, (Gabriel) Daniel Fahrenheit (Germany: 1686-1736) adopted a fixed point scale of temperature. The Fahrenheit scale sets the zero at the freezing point of a salt-water mixture and 100 at approximately body temperature. In 1742, Anders Celsius (Sweden: 1701-1744) described a mercury thermometer that had the zero of the scale set at the freezing point of pure water and 100 degrees set at the boiling point of pure water. The Celsius system is sometimes referred to as the centigrade system. The Kelvin scale, named after Lord Kelvin (William Thomson) (Scotland: 1824-1907), sets zero at the absolute zero of temperature (at which the motions of atoms and molecules practically stops) and uses degrees that are the same size as the Celsius system. The Kelvin scale is related to the Celsius scale by the following relation: TK- TC 273.2 where TK is the temperature in Kelvin and TC is the temperature in C. The Celsius scale is related to the Fahrenheit scale by: TF-(TC*95) +32 where TF is in F The following table provides test cases that provides test cases that can be used for verifying your program and testing the software (this table was generated using Microsoft Excel, see the file GNG1106LabITestCases.xls,). Temperature Celsius (TC) Kelvin (TK) (input) Fahrenheit (TF) (TC * 9/5+32) 26.80 126.80 726.80 80.24 260.24 1,340.24 400 1000 Start with the GNG1106Template.c and modify using the following guidelines to create your program. Local Variables degreek: for containing the Kelvin temperature degreeF: to contain the Fahrenheit temperature. Logic Prompt the user for a temperature in Kelvin with Please enter a temperature in degrees Kelvin. .Read the value typed at the keyboard into the variable degreek Call the function convertKtoF0 to convert a value in Kelvin to Fahrenheit. Display the results with a message of the following form: "Kelvin: 300 Fahrenheit: 80.24" The function convertKtoF0 Local Variables . degreeF: for computing the temperature in Fahrenheit. Return Value: The value of the temperature in degrees Fahrenheit. Calculate the Celsius temperature and store its value in degreec using: TC IK - 273.2 Calculate the Fahrenheit temperature and store its value in degreeF using: TF (TC 9/5)+32 Return the value in degreeF After completing your program, for each test case, capture the program output and insert into your lab report. your working program to the TA and the output inserted into the lab report Show D. Exercise: Programming Model (10 points) Insert your program from Part C into the Code Memory in the programming model on the last page of the lab report. Remove comments and modify the presentation so that both functions can be seen. Modify the programming model to show how the working memory is changed by the program. Use the "?" as the variable value when it is created with a declaration. Update the variable value as you trace the program Use arrows to show how values are copied between the working memory allocated to the function main and the working memory allocated to the function converttoF. (in this case, there are 2 parts of working memory, one is allocated to the main function and the other to the function convertKtoF). Also update the contents of the console window to show the input and output during program execution. You may wish to print a copy of the last page before coming to the lab on paper if you are more comfortable filling out the page by hand rather than using Word to complete the electronic version. Show the results to your TA
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started