Write a matlab script that will prompt the user for a temper
Write a matlab script that will prompt the user for a temperature in degrees Celsius, and then ask theuser whether he/she wants to convert from degrees Celsius to degrees Fahrenheit or Kelvin. Thescript will print the corresponding temperature in the scale specified by the user. For example,the output looks like this:
Please enter the temperature in deg C: 29.3 Do you want to convert to deg Fahrenheit (F) or Kelvin (k) 29.3 deg C is equivalent to 84.7 deg F. The format of the output should be exactly as specified above. The conversions are: The format of the output should be exactly as specified above. The conversions are 9 F = C+32 K = C + 273.15Solution
% this for prompting a user for a temp in C and %print a temp either in K or F as specified by the user C=input(\'Enter temperature in degrees C:\'); %user specification j=input(\'Do you want K or F?\'); %error check while j~=K && j~=F disp(\'Please enter K or F\') j=input(\'Enter K or F now:\'); end if j==F F=9/5*C+32; fprintf(\'The temperature in degrees F is %.2f\ \',F); else K=C+273.15; fprintf(\'The temperature in degrees Kis %.2f\ \',K); end