Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- const float PAPER_COPY = 2;
- const float HARD_COPY = 5;
- const float TAX_RATE = 0.06;
- const float DISCOUNT_RATE = 0.10;
- int main()
- {
- cout << fixed << showpoint << setprecision(2);
- float bookCost; // Represents the cost of a book
- char action; //
- int checkedOut; // Variable for number of books checked out
- int customerNumber; // to keep track of total number of customers
- bool customerFinished; // Boolean for satisfying whether or not the customer is finished purchasing
- float totalSale; // Variable for total cost of the purchase (not including tax and discount)
- float totalDiscount; // Total discount for a purchase
- float discountAmount; // Discount for a single book
- customerFinished = false;
- float totalcustomerSalesWithoutTax; // total customer sales without tax
- float MaxcustomerSale; // Maximum Sale of all customers
- float totalCustomerDiscounts; // The combined discount of all customers
- //float taxAmount; // amount of tax
- float customerCost; // tax + sales
- cout << "Welcome to Book Store." << endl;
- cout << "Enter \"c\" to checkout a new customer, or \"q\" to close batch and print a daily report." << endl;
- cin >> action;
- cout << endl;
- customerNumber = 0;
- while (action != 'q' && action != 'Q') // Outer Loop
- {
- if (action == 'c' || action == 'C')
- {
- customerFinished = false;
- checkedOut = 0;
- totalDiscount = 0;
- totalSale = 0;
- MaxcustomerSale = 0;
- totalcustomerSalesWithoutTax = 0;
- totalCustomerDiscounts = 0;
- customerNumber++;
- while (!customerFinished)
- {
- bookCost = 0;
- while (bookCost <= 0)
- {
- cout << "Customer " << customerNumber << endl;
- cout << "Enter the cost of book: " << endl;
- cin >> bookCost;
- }
- checkedOut++;
- char bookCover; // type of book cover hard/paper
- cout << "Enter \"h\" for HARD COPY, any other key for PAPER_COPY: " << endl;
- cin >> bookCover;
- if (bookCover == 'h' || bookCover == 'H')
- {
- bookCost += HARD_COPY;
- //cout << bookCost << endl;
- }
- else {
- bookCost += PAPER_COPY;
- }
- totalSale += bookCost;
- char discount;
- cout << "Enter \"d\" if customer receives a discount, any other key if they don't:" << endl;
- cin >> discount;
- if (discount == 'd' || discount == 'D')
- {
- discountAmount = DISCOUNT_RATE * bookCost;
- totalDiscount += discountAmount;
- }
- char checkout; // Customer wants to check out
- cout << "Enter \"c\" to check out another book, any other key to total Customer 1: " << customerNumber << endl;
- cin >> checkout;
- cout << endl;
- if (checkout != 'c' || checkout != 'C')
- {
- customerFinished = true;
- float totalsaleDiscount = (totalSale - totalDiscount);
- customerCost = (totalSale - totalDiscount) * (1.0 * TAX_RATE);
- float customerCostTax = customerCost + totalsaleDiscount;
- cout << "Customer " << customerNumber << ":" << endl;
- cout << "Total books checked out: " << checkedOut << endl;
- cout << "Total before tax and discount: " << totalSale << endl;
- cout << "Total Sale for Customer " << customerNumber << ": " << customerCostTax << endl;
- cout << endl;
- if (totalSale >= MaxcustomerSale)
- {
- MaxcustomerSale = totalSale;
- }
- totalcustomerSalesWithoutTax += (totalSale - totalDiscount);
- totalCustomerDiscounts += totalDiscount;
- }
- }
- }
- }
- cout << "Welcome to the Book Store. " << endl;
- cout << "Enter \"c\" to checkout a new customer, or \"q\" to close batch and print daily report. " << endl;
- cin >> action;
- cout << endl;
- //For the daily report
- float taxAmount = totalcustomerSalesWithoutTax * TAX_RATE;
- float avgSale = totalcustomerSalesWithoutTax / (float)customerNumber;
- cout << "Average customer sale: " << avgSale << endl;
- cout << "Max customer sale:" << MaxcustomerSale << endl;
- cout << "Total daily sales: " << totalcustomerSalesWithoutTax + taxAmount << endl;
- cout << "Tax: " << taxAmount << endl;
- cout << "Discount: " << totalCustomerDiscounts << endl;
- cin.get();
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement