COSC 071: Computer Science I

Project 2
Spring 2007

Implementation (only) due Tue, Mar 13 @ 5 PM
6 points

Congratulations! The folks at Wisemiller's were so pleased with your program for calculating their costs and sales for their Chicken Madness that they need another favor. Even though they didn't give you a Wisey's gift card, they want you to modify your program for Project 1 so they can calculate their costs and sales using historical data.

They track the number of sandwiches they make and the cost of foodstuff by the week of the semester, keeping the figures in an Excel spreadsheet. They have saved the numbers from fall semester in a text file named p2.dta, which you can retrieve from my top-level directory on seva using the command

seva% cp ~maloofm/p2.dta ./

The file consists of six columns. The first column is the week of the semester, the second is the number of sandwiches they actually produced, and the third through sixth columns are the prices of rolls, chicken, cheese, and produce, respectively. The first two lines of the file are

1 119 0.83 6.45 3.69 0.51
2 66 0.45 6.92 3.96 1.89

Your program should read the information from this file and for each week, calculate the cost of goods, gross sales, and net sales. After processing all of the weeks, the program should print Wisemiller's total costs, total gross sales, and total net sales for the semester. Sample output:

Week     Cost    Gross      Net
   1   178.26   708.05   529.79
   2   108.90   392.70   283.80
 ...      ...      ...      ...
  15   124.73   434.35   309.62

Total Cost: $2321.98
Total Gross Sales: $8335.95
Total Net Sales: $6013.97

Needless to say, Wisemiller's sales figures are confidential, so after you deliver your software, they will run it on data from other semesters. Translation: Your program should work not only for the data in p2.dta, but also for other files in the proper format. Indeed, the TAs will use additional data sets to grade your program. (To make things easier for us, your program should always read from a file named p2.dta.)

Your program will need to perform light error checks. Specifically, it should report if there are missing records (i.e., lines), and if there are zero or negative values in the input. It should also report if there are problems with reading the file. (The file will contain only numbers. The first and second columns will always contain an integer. The remaining columns will always contain floating-point values.)

Instructions for 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
 * TA: <TA's name>
 * COSC 071, Spring 2007
 *
 * In accordance with the class policies and Georgetown's Honor Code,
 * I certify that, with the exceptions of the lecture notes and those
 * items noted below, I have neither given nor received any assistance
 * on this project.
 *
 * Description: <Describe your program>
 */

When you are ready to submit your program for grading, use the submit program. Both submit.jar and the file containing your program should be in the same directory. This assignment's label is p2. Assuming the file you want to submit is p2.cc, then to submit you enter the command

seva% java -jar submit.jar -a p2 -f p2.cc
Make sure you submit the file containing your program's source, not its executable code; that is, do not submit a.out.

Once you've submitted your project, it is a good idea to keep a copy on seva, which preserves the modification date and time and ensures that you will have a backup copy of your project. If we lose your project or submit 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 are listed on the main page. You must submit your project before 5 PM on the due date.

Plan B

The submit program is pretty reliable, but it is software. If it is three minutes before the deadline and the submit program breaks, here's Plan B. You are to mail your program to our grading account. The syntax for this command is
seva% mail -s "<netid>.cc" cosc071@cush < <filename>
Assume that I want to submit my file named p2.cc. Then I would type
seva% mail -s "maloofm.cc" cosc071@cush < p2.cc
This command sends mail with the subject "maloofm.cc" to our grading account (cosc071@cush). The body of the e-mail is the contents of the file p2.cc. Use Plan B only if you have made sure that submit is truly broken. Finally, don't send normal mail to this account because no one will be checking it regularly.