Lab 4 - A Ticket Machine

Due - Friday, October 8, 2004 - 5PM

In this lab, you will write a program that simulates a machine that dispenses train tickets. Your program will prompt the user for information about her destination, the time of day she wishes to travel, and her age. Based on the information received, your program will display the price of the ticket the user wishes to purchase. An example run of your program might look as follows:

   (1) Grand Central Station
   (2) Greenwich
   (3) Stamford
   (4) Bridgeport
Enter number of destination > 2
Peak or Off-Peak Travel (enter p or o) > p
Adult (12-64), Child (0-11), or Senior (64+) (enter a, c, or s) > a
Your total is: $15.00

The pricing scheme is as follows:

DestinationPeakOff-Peak
Grand Central Station
Adult17.00
Child10.25
Senior10.25
Adult13.25
Child8.25
Senior8.25
Greenwich
Adult15.00
Child8.25
Senior8.25
Adult11.25
Child6.25
Senior6.25
Stamford
Adult10.00
Child3.25
Senior3.25
Adult6.25
Child1.25
Senior1.25
Bridgeport
Adult5.00
Child1.00
Senior1.00
Adult3.25
ChildNo charge
SeniorNo charge

Implementation Hints

You should first prompt the user for all of the relevant information. Using a series of if/else statements, determine the price of the ticket the user wishes to purchase, and finally print the result for the user.

You are responsible for the design of this program. You must decide how to break your program into functions. Part of your grade will be based on your design and no design points will be awarded to programs that use only a main function.

Part 1 - Due - Monday, October 4, 2004 - 8:35AM

Submit a program design and series of test cases. Your design should consist of the functions you plan to implement, the input and output of each function, and an algorithm for each function (including main) which describes its behavior. Your test cases should describe a series of tests you plan to perform to ensure that your program functions correctly. An example test case might look as follows:
Test case 1
-----------
Destination: 3
Ticket type: Peak
Age: Senior
Expected result: 3.25

Part 2 - Due - Friday, October 8, 2004 - 5PM

Because of the fall break, this lab is due on Friday instead of the following Monday. By 5PM on Friday, email me a copy of your .c file. Make SURE you send me the file that ends with .c! During your lab period on Oct 18/19, you will be expected to demonstrate your program. Your grade will depend on part 1, the code your submit for part 2, and your demonstration.
  1. Make sure that each function is well documented. Your documentation should specify the type and role of the input paramaters and ouput.
  2. Copy and paste the output of your program to the bottom of your program itself. Make sure the output is a comment. That means, put a /* before the output and a */ after the output.

Sami Rollins