Programming 2

# Programming 2 - Problem Source Blackboard Programming 2...

This preview shows pages 1–3. Sign up to view the full content.

Problem Source: Blackboard Programming 2 Number 1 Given: Temperature in Celsius, Temperature in Fahrenheit Required: Whether or not temperatures are equal Solution: Start Input TempF TempC TempFtoC = FtoC (Temp F) |TempFtoC – TempC|<0.5 Output TempF is not equal to TempC Output TempF is equal to TempC Stop % FequalC.m Tran, Nathaniel 16184-F % Compares temperature in Celsius to Temp in Fahrenheit TempF = input( 'Enter Temperature in degrees Fahrenheit:' ); TempC = input( 'Enter Temperature in degrees Celsius:' ); TempFtoC = FtoC(TempF); if abs(TempFtoC-TempC)<0.5 fprintf ( '\n %.1f F is equivalent to ' , TempF) fprintf ( '%.1f C' , TempC) else fprintf ( '\n %.1f F is not equivalent to ' , TempF) fprintf ( '%.1f C' , TempC) end Enter Temperature in degrees Fahrenheit:45 Enter Temperature in degrees Celsius:45 45.0 F is not equivalent to 45.0 C>>

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

View Full Document
Enter Temperature in degrees Fahrenheit:32 Enter Temperature in degrees Celsius:0 32.0 F is equivalent to 0.0 C>> Enter Temperature in degrees Fahrenheit:72 Enter Temperature in degrees Celsius:22.2 72.0 F is equivalent to 22.2 C>>
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

Programming 2 - Problem Source Blackboard Programming 2...

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

View Full Document
Ask a homework question - tutors are online