//A wholesale book dealer needs a program to write invoices for book
orders that
//he takes over the phone. Each order usually consists of multiple
copies of several
//book titles. The program should ask the user if there is an order to
process.
//If the user responds yes, the program should then ask for the price of
the first book
//in the order and the number of such books. The program should then
display the cost of
//these books, including a 7.5% sales tax. Then it should ask for the
price of the second
//book in the order and the number of such books, and display the cost
of these books. The
//program should continue in this way, processing the books in the first
order. When there
//are no more books in the order, the program should display the total
cost of the order.
//Then the program should ask if there is another order. If there is
one, the program should
//process it as just described. If there are no more orders, the program
should display the
//total number of orders processed, the total number of books sold, and
the total receipts.
//Use nested while loops

my solution is following which doesn't work properly!
#include <iostream>

using namespace std;

int main()
{
     double price, cost, total_cost=0, total_receipt=0;
     const double SALES_TAX = 0.075;
     int number, total_number=0, total_order=0;
     double response;

     cout << "~~~~~BOOKSTORE~~~~~~" << endl;

     cout << "DO YOU WISH TO PROCEED (0 OR 1): ";




         while ((response=(cin.get())) == '1')
         {
         cout << endl;
         cout << "ENTER PRICE OF THE BOOK: ";
         cin >> price;
         cout << "ENTER COPIES OF THE BOOK: ";
         cin >> number;
         cost = number * price * (1+SALES_TAX);
         total_cost += cost;
         total_number += number;
         cout << "NUMBER OF BOOKS: " << number << " PRICE: " << price <<
" COST: " << cost;
         cout << endl;
         cout << "IS THERE ANOTHER BOOK TO PROCEED? ";

         while ((cin.get()) == '0')
         {

             cout << "TOTAL COST: " << total_cost << endl;;
             ++total_order;
             total_receipt += total_cost;
             break;
         }
         cout << endl << "DO YOU WISH TO PROCEED (0 OR 1)" << endl;
         }



     cout << endl;
     cout << "TOTAL ORDERS: " << total_order << " TOTAL NUMBER " <<
total_number << " TOTAL RECEIPT " << total_receipt;
     cout << endl;

}

Reply via email to