Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

10. Write a program to calculate a temperature provided by the user into a diffe

ID: 3736012 • Letter: 1

Question

10. Write a program to calculate a temperature provided by the user into a different unit system. The program should ask the user to enter a temperature in units of degrees Fahrenheit. The program should the user to choose a unit system they would like to have the value converted into, using a menu. The menu should display the choices "deg C", "K, and "deg R', which should be stored in a cell array. The program should display the output in a sentence formatted as shown below. The actual values in the sentence should change appropriately as the user input and menu selection change then ask Choose a Snal unt deg C deg R Sample Input/ Output Enter the tenperature [deg F1 -129 Menu Choices K The equivalent temperature to-129 deg P is 184 K. You are to write this program twice, using two different methods as indicated below. Note that in neither case may you use conditional statements, even if you know how to do so. a. The program should first convert the temperature in degrees Fahrenhei to all three other unit systems (degrees Celsius, kelvin, degrees Rankine) and store the results in a vector. It should then generate the report b. The program should perform ONLY the specified calculation, not all three, then generate the report. Hint: Stoe the necessary conversion factors in a matrix.

Explanation / Answer

%part a m={'deg C' ,'K','deg R'}; t=input('Enter the temperature [deg F]: '); choice=menu('Choose a final unit',m); eqT=[(t-32)/1.8;(t+459.67)*5/9;t+459.67]; fprintf('The equivalent temperature to %i deg F is %i %s. ',t,round(eqT(choice)),m{choice}) %part b m={'deg C' ,'K','deg R'}; t=input('Enter the temperature [deg F]: '); choice=menu('Choose a final unit',m); conversion={@(t)(t-32)/1.8;@(t)(t+459.67)*(5/9);@(t)t+459.67}; eqT=conversion{choice}(t); fprintf('The equivalent temperature to %i deg F is %i %s. ',t,round(eqT),m{choice})

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote