Celsius to Fahrenheit or vice versa
조회 수: 32 (최근 30일)
이전 댓글 표시
Creating a program to convert Celsius to Fahrenheit
댓글 수: 2
Walter Roberson
2020년 1월 9일
이동: DGM
2024년 5월 2일
We don't know given that little information.
T*9/5+32
채택된 답변
Amit
2014년 1월 21일
disp('This program convert Celsius to Fahrenheit');
Celsius=input('Write a temperature in Celsius and you''ll have the result in Fahrenheit: ');
disp([ 'x = ' num2str(Celsius) ' Celcius and y = ' num2str(Celsius*1.8+32) ' Fahrenheit'])
댓글 수: 1
Amit
2014년 1월 21일
For both cases:
disp('This program convert Celsius to Fahrenheit');
val = input('Type 1 for Celcius to Farenheit and Type 2 for vice versa: ');
switch val
case 1
Celsius=input('Write a temperature in Celsius and you''ll have the result in Fahrenheit: ');
disp([ 'x = ' num2str(Celsius) ' Celcius and y = ' num2str(Celsius*1.8+32) ' Fahrenheit']);
case 2
Faren=input('Write a temperature in Farenheit and you''ll have the result in Celcius: ');
disp([ 'x = ' num2str(Faren) ' Fahrenheit and y = ' num2str((Faren-32)/1.8) ' Celcius ' ]);
end
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!