CS 157 Spring 2001                       Assignment 3 – Selection using IF                                            100 points

 

Assigned: 01/31/2001

Due: 02/07/2001 at the start of class

 

Pre-Lab (Do Before Lab):  Bring an empty (or nearly empty) disk (keep any .c files you create, but other files can be deleted). Plan out sequence of statements needed for program.

 

Main Assignment:

We are writing a program to help estimate expenses for a round-trip car trip, focusing on gas costs. Your program gets as input: the distance in miles between the two places, the expected average miles per hour, the expected miles per galloon that the car gets in city driving, the expected price per galloon cost of gas during the trip. Assume that if the expected average speed is greater than 50 then the miles per galloon will increase by 10%. Your program will print a report showing for the customer, all basic information including the total cost; see the example below.

To keep your job simpler, we will assume that the order-entry typists are infallible (thus don't re-prompt the user for correct data -- I MEAN IT, DON'T ADD THE EXTRA CAPABILITY, at least not in the version you hand in).

 

Sample interaction with the user:

 

Welcome to the Fuel Cost Estimator Program

 

Please enter the number of miles between cities: 120

 

Please enter the expected miles per hour:  65

 

Please enter the expected miles per galloon: 20.5

 

Please enter the expected cost per galloon: 1.359

 

=========================================================

 

Estimate for Customer:

 

Miles:  One Way:     120.0  

        Round Trip:  240.0

 

MPG:  City:  20.5

      Trip:  22.6

 

Galloons:   10.64

Price:       1.359

Cost:       14.46

 

=========================================================

 

Hand-in:

     1) Listing of the program

     2) Disk with  .c source file plus .exe executable file.

 

NAME YOUR PROGRAM FILE yourlastname3.c

 

Miscellaneous:

Make the output of your program like mine. It should be in neat columns – use printf formatting to line up the numbers.

 

MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors). You can test your program on the above example, but make sure you test it on other data as well - I will! Your program needs to be able to handle any valid inputs. Hint – what will cause the program to act differently? Ask the questions in the exact order shown, otherwise your program will not work on my data.

 

Remember: Indentation, meaningful variable names, and meaningful comments. Weaknesses in any of these could result in points off. You MUST include comments that explain your program in order to get full credit. Also, make sure you put YOUR NAME and e-mail address in comments at the beginning of the program.