hw5p2 - fah=temp-459.69;...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
cel=0; fah=0; kel=0; ran=0; Tcel=0; Tfah=0; Tkel=0; Tran=0; n=0; c=0; m=0; cont = 'y'; while cont =='y' u=input('Input temperature units: ', 's'); if u== 'C' || 'F' || 'K' || 'R' if u=='C' n = n+1; temp=input('Input temp: '); cel=temp; fah=((5/9)*temp)+32; kel=temp+273.15; ran=((9/5)*temp)+491.69; celcius(n)=kel; fahrenheit(n)=fah; kelvin(n)=kel; rankine(n)=ran; cont=input('Input another temp? y or n: ','s'); elseif u=='F' n = n+1; temp=input('Input temp: '); cel=(5/9)*(temp-32); fah=temp; kel=((5/9)*(temp-32))+273.15; ran=temp+459.69; celcius(n)=kel; fahrenheit(n)=fah; kelvin(n)=kel; rankine(n)=ran; cont=input('Input another temp? y or n: ','s'); elseif u=='K' n = n+1; temp=input('Input temp: '); cel=temp-273.15; fah=(9/5)*(temp-273.15)+32; kel=temp; ran=((9/5)*(temp-273.15))+491.69; celcius(n)=kel; fahrenheit(n)=fah; kelvin(n)=kel; rankine(n)=ran; cont=input('Input another temp? y or n: ','s'); elseif u=='R' n = n+1; temp=input('Input temp: '); cel=(5/9)*(temp-491.69);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fah=temp-459.69; kel=((5/9)*((temp-459.69)-32))+273.15; ran=temp; celcius(n)=kel; fahrenheit(n)=fah; kelvin(n)=kel; rankine(n)=ran; cont=input('Input another temp? y or n: ','s'); end else u=input('Invalid unit. Enter valid unit: ','s'); end end for c=1:1:n; Tcel=Tcel + celcius(c); Tfah=Tfah + fahrenheit(c); Tkel=Tkel + kelvin(c); Tran=Tran + rankine(c); end AvgCel=Tcel/n; AvgFah=Tfah/n; AvgKel=Tkel/n; AvgRan=Tran/n; A fprintf('\n Temperatures \n') fprintf(' Celcius Fahrenheit Kelvin Rankine\n') fprintf(' C F K R \n') for m=1:1:n fprintf('%10.2f %10.2f %10.2f %10.2f\n', celcius(m), fahrenheit(m), kelvin(m), rankine(m)) end fprintf('Average temp in celcius: %.2f\n', AvgCel) fprintf('Average temp in fahrenheit: %.2f\n', AvgFah) fprintf('Average temp in kelvin is: %.2f\n', AvgKel) fprintf('Average temp in rankine is: %.2f\n', AvgRan)...
View Full Document

Page1 / 2

hw5p2 - fah=temp-459.69;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online