Inventory code

Thread Starter


Joined Nov 28, 2006
The program menu is shown below

(1) Load inventory
(2) Add new animal entry
(3) Change animal count
(4) Create report
(5) Save and quit
(6) Exit (don't save)
Choose an item (1-6):
There are five possible actions that can be carried out.

Loading an inventory. This loads an existing inventory from a file. The program will prompt for a filename and produce error messages if the file does not exist or cannot be read. When the file is read, it will be checked for correctness and the appropriate message displayed if it is not correct. The user will be returned back to the menu. The file contains names of animals and their quantities in a format that you will create. After reading the entire file, the inventory will be stored as a linked list, with each element containing the quantity and type of animal. This list must always be kept in alphabetic order.
Add new animal inventory. This allows a new animal to be added to the inventory. Of course, an inventory must already have been loaded. The user is prompted for an animal name and quantity. If the animal does not exist a new entry is created, if not the existing animal's count is updated and a message shown to that effect.
Change animal count. The user is prompted for a name and quantity to be added or removed, if the animal does not exist the user is notified that a new animal needs to be created and returned to the menu.
Create report. This prints out the entire inventory, in order, with the animal names left aligned and the quantities right aligned. The total amount of animals is also shown at the bottom of the report.
Save and quit. The user is prompted for a filename to save the file and write out the linked list in the appropriate format. Error checking is also required here.
Exit. The program exits and does not save the inventory.
At no time should your program exit because of any faults, it should always inform the user of the problem and then return to the menu. This means that error checking must be present within your code for all possibilities. The animal names can have spaces in them like "French hens". Case is ignored when comparing names.

This is a shell to work with. Can anyone help me. I'm short on time. I dont have to asses the Stock option. Leave it out.

// menu.cpp : Defines the entry point for the console application.
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int printMenu();

const int Load = 1;
const int Add = 2;
const int Change = 3;
const int Stock = 4;
const int Report = 5;
const int Save = 6;
const int Exit = 7;

#define Load 1
#define Add 2
#define Change 3
#define Report 4
#define Save 5
#define Exit 6

int main()
int choice = 0;
while ( choice != Exit ) {
// clear screen
choice = printMenu();
switch (choice) {
case Load:
//[prompt user]
//[code and/or function call to load file into list]
cout << "Load\n";
case Add:
//[prompt user]
//[code and/or insert function call]
cout << "Add\n";
case Change:
//[prompt user]
//[code and/or function call to change count]
cout << "Change\n";
case Stock:
//[code and/or function call to do stock check]
cout << "Stock\n";

case Report:
//[code and/or function call to generate report]
cout << "Report\n";
case Save:
// [prompt for filename]
// [code and/or function to write file]
cout << "Save\n";
return 0;
choice = 0;

// Exit
return 0;

int printMenu()
int choice;
cout << "Menu:\n"
<< "(1) Load inventory\n"
<< "(2) Add new animal entry\n"
<< "(3) Change animal count\n"
<< "(4) Stock check\n"
<< "(5) Create report\n"
<< "(6) Save and quit\n"
<< "(7) Exit (don't save)\n";
cout << " Choose an item (1-7): \n";
cin >> choice;
return choice;