COSC 071: Computer Science I

Project 2: Chippy's Currency Conversion Cart Calculator
Fall 2001

C++ Implementation (electronic) due: Oct 15 @ 2:30 PM
5 points

Chappy is so happy with your sail calculator that he recommends your programming services to his cousin Chippy. Chippy performs odd jobs around the marina for a living, and one thing that he does is convert money for boats that are arriving from or departing to foreign island nations. He does this by taking his currency cart out to the docks, where he sells or buys foreign currency for dollars.

Chippy makes money doing this by selling foreign currency at a higher price than he sells it. For example, on a particular day he might sell Icelandic kronors to people on their way to Iceland at a rate of 98Kr for each US dollar, and buy kronors from people arriving back from Iceland at a rate of 102Kr for each US dollar.

Fortunately for Chippy, sailors leaving from the marina where he works only go to one of three countries, so he only needs to keep and be able to convert currencies for Barbados, Fiji, and Iceland. Each day he keeps a record on his computer of the sell and buy prices of each of these currencies. This file has on the first line the numerical day, the numerical month, and numerical year, each separated by a space. The second line has sell and buy prices for Barbados dollars separated by a space. The third line has the sell and buy prices for Fiji dollars separated by a space. The fourth and final line has the sell and buy prices for Iceland Kronor separated buy a space.

Chippy also keeps track of the transactions he makes each day in a separate file. The number of transactions vary by day, so this file varies in its size and number of lines. The first line has the same numerical date format as the other file, so that he can be sure that the two files go together. Chippy is also not a particularly good typist, so sometimes there are errors in letters that he types, though he never types a number wrong. After the first line with the date, each line in this file has the following format:

<s|b> <b|f|i> <amount>
where
<s|b>
is the character s or b, representing selling or buying currency
<b|f|i>
is the character b or f or i, representing transactions in Barbados dollars, Fiji dollars, or Iceland Kronor.
<amount>
is the amount of foreign currency that was exchanged.

The problem that Chippy has is that he is not sure how much money he is making working the cart. What he would like you to do is develop a calculator for him that can take as input the two files whose format is described above and which produces as output a report in the following format:

The Numerical Date

Barbados Dollars Sold
Barbados Dollars Bought
Profit from Barbados Dollars Exchanged

Fiji Dollars Sold
Fiji Dollars Bought
Profit from Fiji Dollars Exchanged

Iceland Kronors Sold
Iceland Kronors Bought
Profit from Iceland Kronors Exchanged

Total Profit from Currency Exchanged

Any errors found in the transaction file should be reported by writing to the screen, but should not stop the processing of other transactions. Additionally, if any error did occur, a single message should be written to the end of the report file stating that the results might not be valid.

You may expect the input files to be named "rates.txt" (for the sell and buy rates) and "transact.txt" (for the file of transactions). The output file should be named chiprept.txt. The contents of two sample files are included below.

rates.txt
2 10 2001
1.94 2.02
2.24 2.51
98.706 102.786

transact.txt
2 10 2001
s b 2943.14
B i 140200
s I 200800
S i 178950
a f 119210
b F 1845.72
s b 1108.14
B f 1.03
s b 872.12 
b F 923.98
b i 102110
s f 7023.18
B b 6020.42
b I 40050
s j 1182.36

A good approach to building this program would be to first make sure that you can read in the proper values from the rates file, and that you can print those out to verify that they are correct. Next, move onto processing the transactions file.

Instructions for Electronic Submission: At the top of the file containing your source code (i.e., the file containing the C++ instructions), place the following header comment, with the appropriate modifications:

//
// Project 2
// Name: <your name>
// E-mail: <e-mail address>
// Instructor: Maloof | Shields
// TA: <TA's name>
// COSC 071-<section number>
// Platform: Solaris (gusun) | Linux | Windows | Macintosh
// Compiler: g++ | Visual C++ | CodeWarrior | Borland  etc.
//
// Description: <Describe your program>
//

Although you may use any C++ compiler to develop your program, it must run under UNIX and must compile using GNU g++. When you are ready to submit your program for grading, if necessary, use ws-FTP to transfer your file from your PC to gusun. Use SSH to logon to gusun, and use pine to e-mail it to your TA with your netid and the suffix ``.cc'' as the subject. To run pine, type at the UNIX prompt:

gusun% pine

When the menu appears, select the item for composing e-mail. Assume that your netid is ab123, the name of your source file is proj1.cpp, and your TA's e-mail address is ``imagoodta@cs.georgetown.edu''.

Type your TA's e-mail address in the To field, and type your netid with the .cc suffix in the Subject field (no spaces before or after). Move the cursor down into the MESSAGE TEXT screen, and type the ^R command. Pine will ask for a file name (e.g., proj1.cpp), which it will then load as your message text. At this point, your screen should look something like the following:

Finally, type ^X to send the e-mail to your TA.

IMPORTANT: Do not send your source code as an attachment. Do not use a mail client other than pine.

If you need to include a message to you TA about your submission, then type the message as a comment in the program.

Once you've submitted your project, it is important to keep an electronic copy on a university machine (e.g., gusun or cssun) that preserves the modification date and time. If we lose your project or the e-mail system breaks, then we will need to look at the modification date and time of your project to ensure that you submitted it before it was due.

The TAs who will be grading your projects this semester is listed on the main page. You must e-mail your project before 4:00 PM on the due date.