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:
Destination
Peak
Off-Peak
Grand Central Station
Adult
17.00
Child
10.25
Senior
10.25
Adult
13.25
Child
8.25
Senior
8.25
Greenwich
Adult
15.00
Child
8.25
Senior
8.25
Adult
11.25
Child
6.25
Senior
6.25
Stamford
Adult
10.00
Child
3.25
Senior
3.25
Adult
6.25
Child
1.25
Senior
1.25
Bridgeport
Adult
5.00
Child
1.00
Senior
1.00
Adult
3.25
Child
No charge
Senior
No 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.
Make sure that each function is well documented. Your documentation should specify the type and role of the input paramaters and ouput.
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.