Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Program: Project 2 (Serendipity Booksellers)
- Author: David Nelson
- Class: CSCI140
- Date: 10/10/2011
- Description: Main Menu Module
- I certify that the code below is my own work.
- Exception(s): N/A
- */
- #include <iomanip>
- #include <iostream>
- #include "bookdata.h"
- //#include "cashier.h"
- #include "invmenu.h"
- #include "reports.h"
- #include "mainmenu.h"
- #include "BookCollection.h"
- using namespace std;
- void cashier();
- BookData book[20];
- int main()
- {
- int menuChoice;
- do
- {
- cout << "\t\t\tSerendipity Booksellers" << endl;
- cout << "\t\t\t\tMain Menu" << endl;
- cout << endl;
- cout << "\t1. Cashier Module" << endl;
- cout << "\t2. Inventory Database Module" << endl;
- cout << "\t3. Report Module" << endl;
- cout << "\t4. Exit" << endl;
- cout << endl;
- cout << "\tEnter your choice: ";
- cin >> menuChoice;
- if (menuChoice < 1 || menuChoice > 4)
- cout << "\aInvalid entry!." << endl;
- if (menuChoice == 1)
- cashier();
- if (menuChoice == 2)
- invMenu(book);
- if (menuChoice == 3)
- reports(book);
- }
- while (menuChoice !=4);
- return 0;
- }
- void Menu::cashier()
- {
- string date, isbn, title;
- int qty,locationInt, bQty;
- double subTotal, salesTax, totalPrice = 0, unitPrice;
- char runAgain;
- cout << "\nSerendipity Booksellers" << endl;
- cout << "Cashier Module" << endl;
- cout << endl;
- cout << "Date: ";
- cin >> date;
- do
- {
- cout << "Quantity of Books: ";
- cin >> qty;
- cout << "ISBN: ";
- cin >> isbn;
- locationInt = findBook(book, isbn);
- if(locationInt == -1)
- {
- cout << "Cannot locate ISBN" << endl;
- cout << "Would you like to enter a new ISBN? [Y/N]: ";
- cin >> runAgain;
- }
- else
- {
- title = book[locationInt].getTitle();
- unitPrice = book[locationInt].getRetail();
- if(qty > book[locationInt].getQty())
- {
- cout << "Not enough books\n";
- break;
- }
- else
- {
- bQty=book[locationInt].getQty();
- book[locationInt].setQty(bQty-qty);
- cout << "\nSerendipity Booksellers\n" << endl;
- cout << "Date: " << date << endl;
- cout << "QTY\tISBN\t\tTITLE\t\t\t\tPRICE\t\tTOTAL" << endl;
- cout << "-----------------------------------------------------------------------------" << endl;
- cout << qty << "\t" << setw(13) << isbn << " " << setw(30) << left << title << "$" << setw(6) << right << showpoint << setprecision (2) << fixed << unitPrice << "\t $" << setw(6) << right << showpoint << setprecision (2) << fixed << (qty * unitPrice);
- cout << endl << endl;
- subTotal = qty * unitPrice;
- salesTax = subTotal * .06;
- totalPrice = subTotal + salesTax;
- cout << "Do you want to add another book?: ";
- cin >> runAgain;
- }
- }
- while (runAgain !='N' && runAgain !='n')
- {
- if (runAgain !='Y' && runAgain !='y' && runAgain !='N' && runAgain !='n')
- cout << "\aInvalid entry!" << endl;
- else if(runAgain == 'Y' || runAgain == 'y')
- {
- cout << endl;
- cout << "Quantity of Books: ";
- cin >> qty;
- cout << "ISBN: ";
- cin >> isbn;
- locationInt = findBook(book, isbn);
- if(locationInt == -1)
- {
- cout << "Cannot locate ISBN\n";
- cout << "Do you want to add another book?: ";
- cin >> runAgain;
- }
- else
- {
- title = book[locationInt].getTitle();
- unitPrice = book[locationInt].getRetail();
- if(qty > book[locationInt].getQty())
- {
- cout << "Not enough books\n";
- break;
- }
- else
- {
- bQty=book[locationInt].getQty();
- book[locationInt].setQty(bQty-qty);
- cout << "QTY\tISBN\t\tTITLE\t\t\t\tPRICE\t\tTOTAL" << endl;
- cout << "-----------------------------------------------------------------------------" << endl;
- cout << qty << "\t" << setw(13) << isbn << " " << setw(30) << left << title << "$" << setw(6) << right << showpoint << setprecision (2) << fixed << unitPrice << "\t $" << setw(6) << right << showpoint << setprecision (2) << fixed << (qty * unitPrice);
- cout << endl << endl;
- subTotal = subTotal + (qty * unitPrice);
- salesTax = salesTax + (subTotal * .06);
- totalPrice = totalPrice + (qty * unitPrice) + (subTotal * .06);
- cout << "Do you want to add another book?: ";
- cin >> runAgain;
- }
- }
- }
- }
- if(locationInt != -1)
- {
- cout << "\nSerendipity Booksellers\n" << endl;
- cout << "Date: " << date << endl;
- /* cout << "QTY\tISBN\t\tTITLE\t\t\t\tPRICE\t\tTOTAL" << endl;
- cout << "-----------------------------------------------------------------------------" << endl;
- cout << qty << "\t" << setw(13) << isbn << " " << setw(30) << left << title << "$" << setw(6) << right << showpoint << setprecision (2) << fixed << unitPrice << "\t $" << setw(6) << right << showpoint << setprecision (2) << fixed << subTotal;
- */ cout << endl;
- cout << endl;
- cout << "\t\t\tSUBTOTAL:\t\t\t\t $" << right << setw(6) << fixed << showpoint << setprecision(2) << subTotal << endl;
- cout << "\t\t\tTAX: \t\t\t\t $" << right << setw(6) << fixed << showpoint << setprecision(2) << salesTax << endl;
- cout << "\t\t\tTOTAL: \t\t\t\t $" << right << setw(6) << fixed << showpoint << setprecision(2) << totalPrice << endl;
- cout << endl;
- }
- do
- {
- cout << "Do you want another transaction?: ";
- cin >> runAgain;
- if (runAgain != 'Y' && runAgain != 'y' && runAgain !='N' && runAgain != 'n')
- cout << "\aInvalid entry!" << endl;
- }
- while (runAgain != 'Y' && runAgain != 'y' && runAgain != 'N' && runAgain != 'n');
- if (runAgain == 'N' || runAgain == 'n')
- {
- cout << "Thank you for shopping Serendipity!\n" << endl;
- break;
- }
- }
- while (runAgain != 'N' || runAgain != 'n');
- return;
- }
Add Comment
Please, Sign In to add comment