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

The mass of the oxygen gas in thé contaIHer 1s 11.0 glans rite a program to calc

ID: 1767242 • Letter: T

Question

The mass of the oxygen gas in thé contaIHer 1s 11.0 glans rite a program to calculate a temperature provided by the user into a different unit system. The program should ask the user to M enter a temperature in units of degrees Fahrenheit. The program should then ask 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 "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 changes. 10. W D deg C deg R Sample Input/Output Enter the temperature [deg F]: -129 Menu choice: K The equivalent temperature to -129 deg F is 1841K 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 Fahrenheit 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 gen- erate the report. Hint: Store the necessary conversion factors in a matrix.

Explanation / Answer

a)

clc

clear all

F= input('Enter the temperature [deg F]:');

T=[(F-32)*5/9; ((F-32)*5/9)+273; F+459.67];

fprintf ('The temperature in deg C is %.4e temperature in Kelvin is %.4f and temperature in Farenheit is %.4g ',T(1),T(2),T(3)');

(b)

clc

clear all

F= input('Enter the temperature [deg F]:');

choice=menu('choose a final unit','deg C', 'K', 'deg R');

T=[(F-32)*5/9; ((F-32)*5/9)+273; F+459.67];

fprintf('The equivalent temperature to %.4e is %.4f ',F,T(choice)');