Need some help with our source code. Can't figure out why our functions don't work. Can someone please give 2 non-CS majors a hand? Any help would be appreciated.
// Function Prototypes
double CashierMod();
int InventoryMod();
double ReportMod();
char BookInfo();
int menu();
// Global Variables
const int NUM_WIDTH = 10;
const int TITLE_WIDTH = 30;
const int ISBN_WIDTH = 20;
const int PRECISION = 2;
const int NUM_BOOKS =20;
const int STR_SIZE = 50;
//Don't know if this goes here??? Got them off my notes from class.
int QtyHand [NUM_BOOKS];
double WholeCost [NUM_BOOKS];
double RetailCost [NUM_BOOKS];
char Date [STR_SIZE];
char isbnNumber [STR_SIZE];
// Sales tax
const double Tax = 0.06;
// Other Variables
double Price, SubTotal, TotalSale;
// The Main Module.
int main ()
{
int choice;
cout << "S & E Book Store\n";
cout << "\tMain Menu\n";
cout << "----------------\n";
cout << "1) Check Out\n";
cout << "2) Inventory\n";
cout << "3) Reports\n";
cout << "4) Book Information\n";
cout << "5) Exit Program\n";
cout << "Enter 1, 2, 3, 4, or 5: \n";
cin >> choice;
while (choice < 1 || choice > 5) // Validate input
{
cout << "Invalid Selection. Enter 1, 2, 3, 4, or 5: ";
cin >> choice;
}
return choice;
cout << fixed << showpoint << setprecision(2);
do
{
choice = menu();
switch(choice)
{
case 1 : CashierMod();
break;
case 2 : InventoryMod();
break;
case 3 : ReportMod();
break;
case 4 : BookInfo();
break;
case 5 : cout << "Exiting program.\n\n";
}
} while (choice != 5);
return 0;
}
// The Cashier Module.
double CashierMod (double SubTotal, double Sales_Tax, double TotalSale)
{
int ISBN, Qty;
char Date [STR_SIZE];
cout << "S & E Book Store\n";
cout << "\tCash Register Menu\n";
cout << "----------------\n";
cout << "Please enter today's date: \n";
cin >> Date; // Example: 10-Nov-2008.
cout << "Enter a valid ISBN: \n";
cin >> ISBN;
while (ISBN != 123)
{
cout << "Invalid selection. Enter a valid ISBN: \n";
cin >> ISBN;
}
cout << "Enter quantity for purchase: \n";
cin >> Qty;
// The Inventory Database Module.
int InventoryMod()
{
int choice;
while (true)
{
//Display the menu and get a choice
cout << endl;
cout << "S & E Book Store\n";
cout << "Inventory Database\n";
cout << "------------------\n";
cout << "1. Look-Up a Book\n";
cout << "2. Add a Book\n";
cout << "3. Edit a Books Record\n";
cout << "4. Delete a Book\n";
cout << "5. Return to the Main Menu\n";
cout << endl;
cout << "Enter your choice:" << endl;
cin >> choice;
switch (choice)
{
case 1: void lookUpbook();
break;
case 2: void addBook();
break;
case 3: void editBook();
break;
case 4: void deleteBook();
break;
case 5: cout << "Returning to main menu." << endl;
break;
}
//Validate and process the menu choice.
while (choice < 1 || choice > 5)
{
cout << "Please enter a number between one and five." << endl;
cin >> choice;
}
} while (choice != 5);
return 0;
}
//Add stub functions for inventory database
int lookUpBook(int binarySearch, int bookInfo)
{
//Get the title of the book to search for
cout << "Enter the title of the book you wish to search for. " << endl;
cin >> Book_Title [NUM_BOOKS] [STR_SIZE];
//Search for the title of the book
int titleResults = binarySearch;
//If titleResults contain -1 the book was not found.
if (titleResults == -1)
cout << "That book was not found." << endl;
else
// //Otherwise titleResults contains the searched book
return bookInfo;
}
At first I was getting linker errors for all my functions. When I compile the program it doesn't show any errors. The main menu comes up but when I choose 1,2,3, 4 or 5 the program exits. I need to be able to a least get it to recognize the functions.
I am JEspin01's partner and I cannot get the program to work even when removing the "return choice;"
I get linker error's
[Linker error] undefined reference to 'menu()'
[Linker error] undefined reference to 'CashierMod()'
[Linker error] undefined reference to 'ReportMod()'
[Linker error] undefined reference to 'BookInfo()'
Id returned 1 exit status
The problem is that in your switch control your function calls are not passing any arguments. You have defined function prototypes with no formal parameter list however your actual function implementations call for several parameters... which are not being passed. This applies to all of your switch controls. I also don't see any function prototypes for the following function calls which is going to be a problem:
1 2 3 4 5 6 7 8 9 10 11 12 13
switch (choice)
{
case 1: void lookUpbook();
break;
case 2: void addBook();
break;
case 3: void editBook();
break;
case 4: void deleteBook();
break;
case 5: cout << "Returning to main menu." << endl;
break;
}
I think you need to reconsider your programs design at this point. Those constant variables probably need to go to start with and you need to reorg your main program loop among other things. As far as deleting a book from inventory, as long as you know how many you actually have in inventory per book, when the user checks out and the CashierMod() function is called you would reduce that count by one, you're not necessarily going to delete a book (or object, you just need to keep track of how many you have. The way your program is designed is going to be a problem though. Can you use classes for this assignment?