CMSC 201
Programming Project One
World Traveler
Out: Tuesday 9/24/02
Original Due Date: Midnight, Tuesday 10/1/02
|
The Objective
The objective of this assignment is to get you familiar with good design
practices, writing in C in a Unix environment, and using functions.
The Background
Ms. Block, Ms. Bogar and three other faculty members from the CSEE
department recently attended the
SIGIR conference that was held in Tampere, Finland. On the way, we
stopped in London for one night and in Stockholm for the weekend. The
conference was from Monday - Thursday in Tampere. After the conference,
we took a bus tour to St. Petersburg, Russia. (See the "Tours" link on the
SIGIR 2002 page). After the Russian tour, we spent the night in Helsinki,
then another night in London before returning home.
Our trip caused us to visit 5 cities in 4 different countries. Each of these
countries was in a different time zone and each used a different currency.
All of Europe uses the Celsius scale for temperatures. It just seemed as if
we were always doing conversions.
The Task
Your "World Traveler" project will allow the user to perform conversions from
these four currencies into US dollars, calculate the time of day (Eastern Time)
from the time in each of the 5 cities visited, and also convert celsius
temperatures into fahrenheit temperatures. Your program must be menu driven
and will involve two different menus, the main menu and a menu of locations.
You will find the following information useful :
- TIME:
- London time is 5 hours ahead of Eastern Time
- Stockholm time is 6 hours ahead of Eastern Time
- Tampere and Helsinki time is 7 hours ahead of Eastern Time
- St. Petersburg time is 8 hours ahead of Eastern Time
- CURRENCY:
- There are 1.5369 dollars per British pound
- There are 0.1062 dollars per Swedish krona
- There are 0.9692 dollars per Euro
- There are 0.0316 dollars per Russian Rouble
- You may use the function CelsiusToFahrenheit() provided on the lecture
notes for temperature conversions.
You MUST use constants (#define) for each of the conversion
factors shown above, both time and currency. You must also use constants for
your menu choices and for any other item where they would be appropriate.
Your program MUST include the following functions. Do
NOT change the function prototypes given below. You may
choose to use more functions if you wish, but these are sufficient.
- void PrintGreeting (void); -- displays a suitable greeting to the
user
- void DisplayMenu (void); -- displays the main menu choices
- int GetMenuResponse (int min, int max); -- gets an integer from the
user between min and max, inclusive and returns that valid integer as the menu
choice.
- void DisplayLocations (void); -- displays the location menu choices
- void ConvertTime (void); -- a high level function that handles all
of the user input, processing, and output dealing with converting time.
- void ConvertCurrency (void); -- a high level function that handles
all of the user input, processing, and output dealing with converting currency.
- void ConvertTemp (void); -- a high level function that handles all
of the user input, processing, and output dealing with converting temperature.
- int ForeignTimeToEastern (int hour, int adjustment); -- changes the
hour (24-hour clock) passed in by the amount of the adjustment yeilding
Eastern Time in 24-hour form
- void PrintInUSForm (int hour, int minutes); -- receives a time in
24-hour form and prints out that time in 12-hour form with AM or PM.
- float ForeignToDollars (float units, float conv); -- accepts the
number of units of a foreign currency and a conversion factor and returns the
equivalent number of US dollars.
- int CelciusToFahrenheit (int celsius); -- returns the fahrenheit
equivalent of the celsius temperature passed in.
- int GetValidInt(int min, int max); -- gets an integer from the
user between min and max, inclusive and returns that valid integer.
You MUST use separate compilation for this project.
gcc -c -Wall -ansi proj1.c
gcc -c -Wall -ansi travel.c
gcc -Wall -ansi proj1.o travel.o
Sample Run
ecs225d-linux-01[101] gcc -c -Wall -ansi proj1.c
ecs225d-linux-01[102] gcc -c -Wall -ansi travel.c
ecs225d-linux-01[103] gcc -Wall -ansi proj1.o travel.o
ecs225d-linux-01[104] a.out
Your Greeting Goes Here
1 - Convert Time
2 - Convert Currency
3 - Convert Temperature
4 - Quit
Enter your choice : 1
Where are you ?
1 - London
2 - Stockholm
3 - Tampere
4 - Helsinki
5 - St. Petersburg
Enter your choice : 1
What time is it ?
hour:
Please enter an integer between 0 and 23 : 22
minutes:
Please enter an integer between 0 and 59 : 15
22:15 London time is 5:15 PM Eastern
1 - Convert Time
2 - Convert Currency
3 - Convert Temperature
4 - Quit
Enter your choice : 1
Where are you ?
1 - London
2 - Stockholm
3 - Tampere
4 - Helsinki
5 - St. Petersburg
Enter your choice : 2
What time is it ?
hour:
Please enter an integer between 0 and 23 : 10
minutes:
Please enter an integer between 0 and 59 : 45
10:45 Stockholm time is 4:45 AM Eastern
1 - Convert Time
2 - Convert Currency
3 - Convert Temperature
4 - Quit
Enter your choice : 1
Where are you ?
1 - London
2 - Stockholm
3 - Tampere
4 - Helsinki
5 - St. Petersburg
Enter your choice : 5
What time is it ?
hour:
Please enter an integer between 0 and 23 : 24
Please enter an integer between 0 and 23 : 18
minutes:
Please enter an integer between 0 and 59 : 60
Please enter an integer between 0 and 59 : 30
18:30 St. Petersburg time is 10:30 AM Eastern
1 - Convert Time
2 - Convert Currency
3 - Convert Temperature
4 - Quit
Enter your choice : 2
Where are you ?
1 - London
2 - Stockholm
3 - Tampere
4 - Helsinki
5 - St. Petersburg
Enter your choice : 1
How many pounds ? 20
20.00 pounds is $ 30.74
1 - Convert Time
2 - Convert Currency
3 - Convert Temperature
4 - Quit
Enter your choice : 2
Where are you ?
1 - London
2 - Stockholm
3 - Tampere
4 - Helsinki
5 - St. Petersburg
Enter your choice : 4
How many euros ? 75
75.00 euros is $ 72.69
1 - Convert Time
2 - Convert Currency
3 - Convert Temperature
4 - Quit
Enter your choice : 2
Where are you ?
1 - London
2 - Stockholm
3 - Tampere
4 - Helsinki
5 - St. Petersburg
Enter your choice : 5
How many roubles ? 1000
1000.00 roubles is $ 31.60
1 - Convert Time
2 - Convert Currency
3 - Convert Temperature
4 - Quit
Enter your choice : 5
5 is not a valid choice
Enter your choice : 3
Enter the celsius temperature : 27
27 celsius is 80 fahrenheit
1 - Convert Time
2 - Convert Currency
3 - Convert Temperature
4 - Quit
Enter your choice : 4
ecs225d-linux-01[105]
Although your output need not be identical to the above,
all information (including the greeting) must be present.
Submitting the Program
You must name your source file that contains main() proj1.c
The file that contains the function definitions should be called
travel.c and the header file should be called travel.h.
To submit your project, type the following at the Unix prompt:
submit cs201 Proj1 proj1.c travel.c travel.h
To verify that your project was submitted, you can execute the
following command at the Unix prompt. It will show all files that
you submitted in a format similar to the Unix 'ls' command.
submitls cs201 Proj1