I feel like I am really close with this, but I keep getting a string of " error: a function-definition is not allowed here before '{' token" errors... I'm a little confused with the entire makefile business all together in that if you're writing a single-file program, do you need a seperate makefile.h to store the function prototypes in, or do they go in your program? Could that be the reason why I am getting this error?
Here's the makefile.h that I have in my header:
int cashier(); int invMenu(); int bookinfo(); int reports(); int lookUpBook(); void addBook(); void editBook(); void deleteBook(); void repListing(); void repWholesale(); void repRetail(); void repQty(); void repCost(); void repAge();
Then here is what I have for the program itself...
#include <iostream>
#include <iomanip>
#include "makefile.h"
using namespace std;
int main()
{
//Starting with the S.Booksellers main menu.
int choice;
do
{
cout << "\t\t\tSerendipity Booksellers\n";
cout << "\t\t\t\tMain Menu\n";
cout << "\n\n\t\t1. Cashier Module\n";
cout << "\n\n\t\t2. Inventory Database Module\n";
cout << "\n\n\t\t3. Report Module\n";
cout << "\n\n\t\t4. Exit\n";
cout << "\n\n\n\t Enter Your Choice:";
cin >> choice;
// Validate the menu selection.
while (choice < 1 || choice > 4)
{
cout << "Please enter a number between 1 and 4: ";
cin >> choice;
}
switch(choice)
{
case 1:
cashier;
break;
case 2:
invMenu;
break;
case 3:
reports;
break;
case 4:
cout << "\n Thank you for visiting Serendipity Books, Bye now!\n";
break;
default:
cout << "\n You must enter a number between 1 and 4 to continue.\n";
}
} while (choice !=4);
return 0;
}
//Inserting Cashier function into mainmenu file.
int cashier()
{
char date[11], title [30], isbn[20];
int bookssold;
double price, subtotal, tax, gtotal;
char again;
do
{
cout << "What is the date? Please use the MM/DD/YY format. ";
cin >> date;
cout << "\nHow many books were purchased? ";
cin >> bookssold;
cout << "\nWhat is the books ISBN number? ";
cin >> isbn;
cout << "\nWhat is the title of the book? ";
cin.ignore(100,'\n');
cin.getline(title, 30);
cout << "\nWhat is the unit price of the book?";
cin >> price;
cout << "\n Do you have another book to enter? Y or N. ";
cin >> again;
} while (again == 'Y' || again == 'y');
subtotal = (price * bookssold);
tax = (subtotal * 0.06);
gtotal = (subtotal + tax);
cout << "\t\t\t\tSerendipity Booksellers\n";
cout << " \n";
cout << " \n";
cout << "Date: "<< date;
cout << " \n";
cout << "Qty\t\tISBN\t\tTitle\t\t\tPrice\t\tTotal\n";
cout << "______________________________________________________________\n";
cout << " \n";
cout << bookssold << "\t" << isbn << "\t" << title << "\t\t" << setprecision(2);
cout << fixed << price << "\t\t" << setprecision(2) << fixed << subtotal << endl;
cout << " \n";
cout << " \n";
cout << "\t\t\t\t Subtotal: " << subtotal << "\n";
cout << "\t\t\t\t Tax: " << tax << "\n";
cout << "\t\t\t\t Total: " << gtotal << "\n";
cout << " \n";
cout << "Thank you for shoping at Serendipity!\n";
return 0;
}
//Inserting Inventory menu into mainmenu file.
int invMenu()
{
int choice;
do
{
cout << "\t\t\tSerendipity Booksellers\n";
cout << " \n";
cout << "\t\t\t\tInventory Database\n";
cout << "\n\n\t\t1. Look up a Book\n";
cout << "\n\n\t\t2. Add a Book\n";
cout << "\n\n\t\t3. Edit a Book's Record\n";
cout << "\n\n\t\t4. Delete a Book\n";
cout << "\n\n\t\t5. Return to the Main Menu\n";
cout << "\n\n\n\t Enter Your Choice:";
cin >> choice;
// Validate the menu selection.
while (choice < 1 || choice > 4)
{
cout << "Please enter a number between 1 and 5: ";
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 << "Return to the Main Menu. \n";
default:
cout << "You must choose a number betwen 1 - 5.";
}
}while (choice !=5);
return 0;
//Creating stub functions to be used later.
void lookUpBook()
{
cout << "You selected Look Up a Book. \n";
}
void addBook()
{
cout << "You slected Add a Book. \n";
}
void editBook()
{
cout << "You selected Edit Book.\n";
}
void deleteBook()
{
cout << "You selected Delete Book.\n";
}
//Inserting Book Info into mainmenu.
int bookInfo()
{
cout << "\t\t\tSerendipity Booksellers\n";
cout << " \n";
cout << "\t\t\t\tBook Information\n";
cout << "\n\nISBN:\n";
cout << "\n\nTitle:\n";
cout << "\n\nAuthor:\n";
cout << "\n\nDate Added:\n";
cout << "\n\nQuantity-On-Hand:\n";
cout << "\n\nWholesale Cost:\n";
cout << "\n\nRetail Price:\n";
return 0;
}
//Inserting Reports menu into mainmenu.
int reports()
{
int choice;
do
{
cout << "\t\t\tSerendipity Booksellers\n";
cout << " \n";
cout << "\t\t\t\tReports\n";
cout << "\n\n\t\t1. Inventory Listing\n";
cout << "\n\n\t\t2. Inventory Wholesale Value\n";
cout << "\n\n\t\t3. Inventory Retail Value\n";
cout << "\n\n\t\t4. Listing by Quantity\n";
cout << "\n\n\t\t5. Listing by Cost\n";
cout << "\n\n\t\t6. Listing by Age:\n";
cout << "\n\n\t\t7. Return to the Main Menu\n";
cout << " \n";
cout << "\n\n\n\t Enter Your Choice:";
cin >> choice;
// Validate the menu selection.
while (choice < 1 || choice > 7)
{
cout << "Please enter a number between 1 and 5: ";
cin >> choice;
}
// Switch statements.
switch(choice)
{
case 1:
void repListing();
break;
case 2:
void repWholesale();
break;
case 3:
void repRetail();
break;
case 4:
void repQty;
break;
case 5:
void repCost();
break;
case 6:
void repAge();
break;
case 7:
cout << "Returning you to the Main Menu...";
break;
default:
cout << "You must enter a number between 1 and 7 to continue.\n";
}
} while (choice !=7);
return 0;
}
}
//creating yet another set of stub functions that will later preform opperations.
void repListing()
{
cout << "You selected Inventory Listing.";
}
void repWholesale()
{
cout << "You have selected Inventory Wholesale Value.";
}
void repRetail()
{
cout << "You have selected Inventory Retail Value";
}
void repQty()
{
cout << "You selected Listing by Quantity.";
}
void repCost()
{
cout << "You selected Listing by Cost.";
void repAge()
{
cout << "You selected Listing by Age.";
}
}
}
I would appreciate any ideas or constructive criticisms... I feel like I'm hitting a brick wall.
thanks,
Kay

New Topic/Question
Reply




MultiQuote





|