MATLAB Write a while loop that will continuously ask the use

MATLAB: Write a while loop that will continuously ask the user to input a temperature value to convert from Celsius to Fahrenheit so long as it is above zero. Run your code to convert

a few numbers and terminate it. Use C = 33, 55, 66, 77 to test your code

Solution

% matlab code convert celsius to fahrenheit

while true
celsius = input(\"Enter temperature in celsius: \");
if (celsius < 0)
break;
end
  
fahrenheit = (9*celsius)/5 + 32;
fprintf(\"Temperature in Fahrenheit: %f\ \ \",fahrenheit);
end

%{
output:

Enter temperature in celsius: 33
Temperature in Fahrenheit: 91.400000

Enter temperature in celsius: 55
Temperature in Fahrenheit: 131.000000

Enter temperature in celsius: 66
Temperature in Fahrenheit: 150.800000

Enter temperature in celsius: 77
Temperature in Fahrenheit: 170.600000

Enter temperature in celsius: -1

%}

MATLAB: Write a while loop that will continuously ask the user to input a temperature value to convert from Celsius to Fahrenheit so long as it is above zero. R

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site