Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Recall that where C and F denote the temperature in Celsius and Fahrenheit, resp

ID: 3561375 • Letter: R

Question

Recall that where C and F denote the temperature in Celsius and Fahrenheit, respectively. Use the input function in MATLAB to prompt the user to enter the temperature in Fahrenheit. Then use the formula above to write code to convert the temperature from Fahrenheit to Celsius. Display the result to the user. Use the input function in MATLAB to prompt the user to enter a number representing the speed in miles per hour. Then write code to compute and display to the user the speed converted into meters per second. Recall that 1 mile = 1609.34 meters.

Explanation / Answer

5)

f=input('Enter the temperature in Fahrenheit: ');
c=(f-32)*(5/9);
fprintf('%0.2f Fahrenheit= %0.2f Celcius ',f,c);

6)

mile=input('Enter the speed in miles per hour: ');
meter=mile*1609.34/3600;
fprintf('%0.2f miles per hour= %0.2f meters per second ',mile,meter);

7)

day=input('Enter the number of days remaining: ');
hour=input('Enter the number of hours remaining: ');
min=input('Enter the number of minutes remaining: ');
second=((day*24+hour)*60+min)*60;
disp(second)

8)

n=input('Enter how many USB flash drive you want to buy: ');
p24= fix(n/24);
x=mod(n,24);
p12=fix(x/12);
x1=mod(x,12);
p4=fix(x1/4);
p1=mod(x1,4)
fprintf('- buy %d 24-packs at $109 per pack for a total of $%d ',p24,p24*109);
fprintf('- buy %d 12-packs at $55 per pack for a total of $%d ',p12,p12*55);
fprintf('- buy %d 4-packs at $19 per pack for a total of $%d ',p4,p4*19);
fprintf('- buy %d singles at $5 per pack for a total of $%d ',p1,p1*5);
total=p24*109+p12*55+p4*19+p1*5;
fprintf('overall total is $%d ',total);