In: Computer Science
1. Temperature in kelvins (K) is related to the temperature in degrees Fahrenheit (°F) by the equation Design a MATLAB program that will do the following a. Prompt the user to enter an input temperature in °F. b. Read the input temperature. c. Calculate the temperature in kelvins in a separate function d. Write out the results with two digits to the right of the decimal (Use the fprintf function). The results should go to the command window.
Code to write in the script file:
% Function to convert temperature in degree Fahrenheit to degree
Kelvin
function temp_in_C = tempCalculate ()
temp_in_F = input("Enter temperature in degree Fahrenheit:
");
temp_in_C = (temp_in_F - 32).*(5./9);
fprintf('Temperature in degree Celsius: %.2f',temp_in_C)
end
Code for command window:
% Calling the function
tempCalculate();
Enter temperature in degree Fahrenheit:
36
Temperature in degree Celsius: 2.22
% One more example
tempCalculate();
Enter temperature in degree Fahrenheit:
56
Temperature in degree Celsius: 13.33
Screenshots for the same:
*NOTE: Drop a comment for queries.