Create a user function to convert degrees F to degrees C Nam

Create a user function to convert degrees F to degrees C. Name the function: F to C 1 input arguments degrees_F 1 output argument degrees_C Use formula C = 5 degree (F - 32)/9 Try sing function from command window. Then create a script and ask the user for temperature in degrees. Use your function F to C. Have your script display the result in a sentence using the fprintf command (show 2 place after the decimal point).

Solution

This is the Mat lab code for converting degrees from F to C:

% Here give temparature as a input in the format of farenheit

degree = input(\'Enter the temparature in farenheit (f):\')

% Here give units of the temarature in \'F\' (Uppercase) or \'f\' (Lowercase)

u= input(\'Enter units of temparature in (F or f) : \')

% Condition checking

if(u == \'F\' || u == \'f\')

     result = (5/9) * (degree - 32) %Here we apply the formula

else

     fprintf(\' Please enter correct input as temparature in Farenheit: \')

     ftc     % Here restrat the programe until enter the correct input

end

fprintf(\' The Result temparture is \',\'% .2f %s = % .2f\", degree, u, result, \'C\') % Here print the converted temparature

 Create a user function to convert degrees F to degrees C. Name the function: F to C 1 input arguments degrees_F 1 output argument degrees_C Use formula C = 5 d

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site