CS 210 - Fundamentals of Programming I

Spring 2006 - Programming Project 1, Part B

70 points

Out: February 23, 2006
Due: March 14, 2006 (Tuesday after spring break)


Part B of this programming project is to implement the program you designed in Part A. The work must be entirely your own except for any help you may receive from the instructor. Name your source file project1.cpp. Submit your source file by emailing it as an attachment to cs210@csserver.evansville.edu by 5pm on the due date. (Make sure you send it to csserver. If you send to just evansville.edu, it will not be delivered.) Also submit a hardcopy of your program to the instructor by 5pm on the due date.


There are a few new implementation criteria:


Other notes:

Example program run

Welcome to the Evansville Distributorship Inventory Program.

This program keeps track of soft drink inventories.  
Please enter the beginning inventory for the following brands:
Coca-Cola: 20
Pepsi: 30
Canada Dry: 10
7Up: 10
A&W: 5

The initial inventory is:

Soda         Cases
------------------
Coca-Cola      20
Pepsi          30
Canada Dry     10
7Up            10
A&W             5

You may choose from the following menu:

   P: Purchase soda
   S: Sell soda
   D: Display inventory

What is your selection?: P

You may choose from the following soda brands:

   1: Coca-Cola
   2: Pepsi
   3: Canada Dry
   4: 7Up
   5: A&W

Please enter the code for the soda you are purchasing: 1

Please enter the number of cases purchased: 10

10 cases of Coca-Cola have been added into the inventory

Do you want to do another action? (y/n): n

The final inventory is:

Soda         Cases
------------------
Coca-Cola      30
Pepsi          30
Canada Dry     10
7Up            10
A&W             5

Have a good day!

Extra Credit (5 points)

For extra credit you may have your program read in the initial soda inventory from a file named week1.dat (rather than entered interactively from the keyboard). This file should consist of 5 integers representing the initial inventories of the 5 brands of soda in the order given in Part A. You may assume that the file contains valid initial inventories (i.e., the integers will be greater than or equal to zero.) When the user chooses to quit, in addition to being displayed on the screen, the current inventory should be written out to a file named week2.dat. It also should consist of 5 integers representing the final inventories of the 5 brands of soda in the order given in Part A.


For example, if week1.dat has the following data:

20
30
10
10
5
Then an example run of this version might look like:


Welcome to the Evansville Distributorship Inventory Program.

This program keeps track of soft drink inventories.  
The initial inventory has been read from file week1.dat.

The initial inventory is:

Soda         Cases
------------------
Coca-Cola      20
Pepsi          30
Canada Dry     10
7Up            10
A&W             5

You may choose from the following menu:

   P: Purchase soda
   S: Sell soda
   D: Display inventory

What is your selection?: P

You may choose from the following soda brands:

   1: Coca-Cola
   2: Pepsi
   3: Canada Dry
   4: 7Up
   5: A&W

Please enter the code for the soda you are purchasing: 1

Please enter the number of cases purchased: 10

10 cases of Coca-Cola have been added into the inventory

Do you want to do another action? (y/n): n

The final inventory is:

Soda         Cases
------------------
Coca-Cola      30
Pepsi          30
Canada Dry     10
7Up            10
A&W             5

This data has been written to file week2.dat.
Have a good day!


Note: In KC-267, when a program is run using Start Without Debugging, the default folder is set to C:\WINDOWS (because the .NET system doesn't trust a program coming from a network drive that it's not debugging), so all input and output files must be in this folder. On the other hand when a program is run using Start Debugging, the input and output files are expected to be in the project folder. If you develop this program on your own machine with the project folder on the local drive, then the output file will be written to the project folder in both cases.


Converted using latex2html on Wed Feb 22 15:09:09 CST 2006