solve this question and show answer step by step do it on matlab 1. (5 pts) Writ
ID: 3184492 • Letter: S
Question
solve this question and show answer step by step do it on matlab
Explanation / Answer
Steps:
Store f value as 1 and k value as 2;
Ask to enter f or k then store this inpu in x (here f for Fahrenheit and k for Kelvin)
Using switch x
if x=f that is x=1 then Ask to enter Celsius value
Fahrenheit=Celsius*9/5+32
if x=k that is x=2 then Ask to enter Celsius value
Kelvin=Celsius+273.15
MATLAB CODE
clc
clear all
f=1;
k=2;
disp('Celsius to Fahrenheit or Kelvin');
x = input('Type f for Farenheit and Type k for Kelvin: ');
switch x
case 1
Celsius=input('Enter a temperature in Celsius: ');
disp([ num2str(Celsius*9/5+32) ' Fahrenheit']);
case 2
Celsius=input('Enter a temperature in Celsius: ');
disp([ num2str(Celsius+273.15) ' Kelvin ' ]);
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.