Docsity

Introduction to C Programming for Engineers - Assignment 5 | CSE A205, Assignments of Engineering

Toggle sidebar
bg1
CSE294A Assignment #5
Professor Miller
1/1
CSE294A Assignment #5
1.5% of course grade
Thisassignmentwillgiveyouthechancetoredeemsomeofthepointslostonthe
midterm.Youwillmerelycompletethesecondpartofthemidtermforthisassignment.
Hereisthedescription.
Forthisprogram,youwillperformasetofconversionsfromFahrenheittoCelsiusor
CelsiustoFahrenheit.TheuserwillfirstenteranFtoconvertfromFahrenheittoCelsius
oraCtoconvertfromCelsiustoFahrenheit.Thentheuserwillenterthreeinteger
values.Thefirstintegerwillbethelowertemperature.Thesecondintegerwillbethe
highertemperature.Andthethirdintegerwillbetheincrementaltemperaturechange.
Yourprogramwillthenconvertallofthetemperatureswithinthatrangebasedonthe
incrementaltemperaturechange.Hereareafewsampleexecutions.
Would you like to convert from Fahrenheit to Celsius (F) or Celsius to Fahrenheit (C)? F
Enter the lower Fahrenheit temperature: 20
Enter the higher Fahrenheit temperature: 40
Enter the incremental temperature change: 2
20F = -6.67C
22F = -5.56C
24F = -4.44C
26F = -3.33C
28F = -2.22C
30F = -1.11C
32F = 0.00C
34F = 1.11C
36F = 2.22C
38F = 3.33C
40F = 4.44C
Would you like to convert from Fahrenheit to Celsius (F) or Celsius to Fahrenheit (C)? C
Enter the lower Celsius temperature: 10
Enter the higher Celsius temperature: 30
Enter the incremental temperature change: 3
10C = 50.00F
13C = 55.40F
16C = 60.80F
19C = 66.20F
22C = 71.60F
25C = 77.00F
28C = 82.40F
Youcanassumethatthevaluesenteredwillbeofthecorrecttype(acharacterforthe
typeofconversionandintegersfortheotherthreevalues),butyoucannotassume
anythingaboutthevalues,soputtheappropriateerrorchecksintoyourcode.
Grading Criteria
0.2% Prompting the user correctly for the 4 values
0.2% Ensuring only a C or F is entered and prompting the user again if not
0.2% Ensuring the higher temperature is actually higher than the lower temperature
0.2% Ensuring the incremental temperature change is greater than 0
0.2% Properly converting from Fahrenheit to Celsius
0.2% Properly converting from Celsius to Fahrenheit
0.3% Properly displaying the output based on the incremental change

Partial preview of the text

Download Introduction to C Programming for Engineers - Assignment 5 | CSE A205 and more Assignments Engineering in PDF only on Docsity!

CSE294A Assignment # Professor Miller 1/

CSE294A Assignment # 1.5% of course grade

This assignment will give you the chance to redeem some of the points lost on the midterm. You will merely complete the second part of the midterm for this assignment.

Here is the description.

For this program, you will perform a set of conversions from Fahrenheit to Celsius or

Celsius to Fahrenheit. The user will first enter an F to convert from Fahrenheit to Celsius

or a C to convert from Celsius to Fahrenheit. Then the user will enter three integer values. The first integer will be the lower temperature. The second integer will be the

higher temperature. And the third integer will be the incremental temperature change.

Your program will then convert all of the temperatures within that range based on the incremental temperature change. Here are a few sample executions.

Would you like to convert from Fahrenheit to Celsius (F) or Celsius to Fahrenheit (C)? F Enter the lower Fahrenheit temperature: 20 Enter the higher Fahrenheit temperature: 40 Enter the incremental temperature change: 2 20F = -6.67C 22F = -5.56C 24F = -4.44C 26F = -3.33C 28F = -2.22C 30F = -1.11C 32F = 0.00C 34F = 1.11C 36F = 2.22C 38F = 3.33C 40F = 4.44C

Would you like to convert from Fahrenheit to Celsius (F) or Celsius to Fahrenheit (C)? C Enter the lower Celsius temperature: 10 Enter the higher Celsius temperature: 30 Enter the incremental temperature change: 3 10C = 50.00F 13C = 55.40F 16C = 60.80F 19C = 66.20F 22C = 71.60F 25C = 77.00F 28C = 82.40F

You can assume that the values entered will be of the correct type (a character for the

type of conversion and integers for the other three values), but you cannot assume

anything about the values, so put the appropriate error checks into your code.

Grading Criteria 0.2% Prompting the user correctly for the 4 values 0.2% Ensuring only a C or F is entered and prompting the user again if not 0.2% Ensuring the higher temperature is actually higher than the lower temperature 0.2% Ensuring the incremental temperature change is greater than 0 0.2% Properly converting from Fahrenheit to Celsius 0.2% Properly converting from Celsius to Fahrenheit 0.3% Properly displaying the output based on the incremental change