Expand|Select|Wrap|Line Numbers
- // Final Project
- #include <iostream.h>
- #include <iomanip.h>
- // Function Prototypes
- void checkout();
- void start_or_startover();
- void receipt();
- void main_function();
- float subtotal, tax, total;
- // Global Variables, makes everything easier
- // Prices
- float laptopprice = 799.99;
- float mouseprice = 12.99;
- float keyboardprice = 29.99;
- float moniterprice = 399.99;
- float usbprice = 16.99;
- float hdmiprice = 24.99;
- float lazerprice = 6.99;
- float powerprice = 9.99;
- // Quantity
- int laptopnumber;
- int mousenumber;
- int keyboardnumber;
- int moniternumber;
- int usbnumber;
- int hdminumber;
- int lazernumber;
- int powernumber;
- int zero;
- int choice_amount;
- int choice;
- // Item chosen, and amount of the item are stored in these variables.
- // Main Function
- int main()
- {
- // do loop shows merchandise
- do
- {
- cout << "(1) HP Pavilion Intel Core 2 Duo Laptop $799.99" << endl;
- cout << "(2) Razer Black Wired Lazer Mouse $12.99" << endl;
- cout << "(3) Ra zer Keyboard Wired $29.99" << endl;
- cout << "(4) HP LCD Flatscreen Moniter $399.99" << endl;
- cout << "(5) SATA USB 8GB Flash Drive $16.99" << endl;
- cout << "(6) HDMI Full 1080p 6ft Cable $24.99" << endl;
- cout << "(7) Lazer Pointer $6.99" << endl;
- cout << "(8) Power Cord $9.99" << endl;
- cout << endl;
- cout << "(9) Total" << endl;
- cout << "(10) Cancel Order" << endl;
- cout << " Please enter the choice number of the electronics that you would like to buy." << endl << endl;
- cin >> choice;
- cout << endl;
- // if the user is done with his/her choices, the sale is totaled.
- if (choice == 9)
- {
- checkout();
- }
- cout << " How many would you like? ";
- cin >> choice_amount;
- cout << endl;
- // The number of each item is asked for here.
- switch (choice)
- {
- case 1:
- total = laptopprice + zero;
- break;
- case 2:
- total = mouseprice + zero;
- break;
- case 3:
- total = keyboardprice + zero;
- break;
- case 4:
- total = moniterprice + zero;
- break;
- case 5:
- total = usbprice + zero;
- break;
- case 6:
- total = hdmiprice + zero;
- break;
- case 7:
- total = lazerprice + zero;
- break;
- case 8:
- total = powerprice + zero;
- break;
- case 9:
- laptopnumber = 0;
- mousenumber = 0;
- keyboardnumber = 0;
- moniternumber = 0;
- usbnumber = 0;
- hdminumber = 0;
- lazernumber = 0;
- powernumber = 0;
- }
- ;}
- while (choice != 9);
- if (choice == 10);
- { start_or_startover(); }
- receipt();
- return 0;
- }
- void start_or_startover()
- {
- cout << "Ferger's Technology Store" << endl;
- }
- void checkout()
- {
- subtotal = (laptopnumber * laptopprice) + (mousenumber * mouseprice) + (keyboardnumber * keyboardprice) + ( subtotal = (laptopnumber * laptopprice) + (mousenumber * mouseprice) + (keyboardnumber * keyboardprice) + ( subtotal = (laptopnumber * laptopprice) + (mousenumber * mouseprice) + (keyboardnumber * keyboardprice) + (moniternumber * moniterprice) + (usbnumber * usbprice) + (hdminumber * hdmiprice) + (lazernumber * lazerprice) + (powernumber * powerprice)));
- tax = subtotal * .0875;
- total = subtotal + tax;
- }
- void receipt()
- {
- cout << "Thank you for your buisness. Here is your receipt." << endl << endl;
- cout << "Items\t\t " << "Number of items purchased \t Price of each item \t Total price" << endl;
- cout.setf(ios::fixed);
- cout << "HP Pavilion Intel Core 2 Duo Laptop \t "<< laptopnumber << "\t\t\t" << "$" << setprecision(2) << laptopprice << "\t\t " << "$" << (laptopnumber * laptopprice) << endl;
- cout << "Razer Black Wired Lazer Mouse \t "<< mousenumber << "\t\t\t" << "$" << setprecision(2) << mouseprice << "\t\t " << "$" << (mousenumber * mouseprice) << endl;
- cout << "Razer Keyboard Wired \t "<< keyboardnumber << "\t\t\t" << "$" << setprecision(2) << keyboardprice << "\t\t " << "$" << (keyboardnumber * keyboardprice) << endl;
- cout << "SATA USB 8GB Flash Drive \t "<< usbnumber << "\t\t\t" << "$" << setprecision(2) << usbprice << "\t\t " << "$" << (usbnumber * usbprice) << endl;
- cout << "HDMI Full 1080p 6ft Cable \t "<< hdminumber << "\t\t\t" << "$" << setprecision(2) << hdmiprice << "\t\t " << "$" << (hdminumber * hdmiprice) << endl;
- cout << "Lazer Pointer \t "<< lazernumber << "\t\t\t" << "$" << setprecision(2) << lazerprice << "\t\t " << "$" << (lazernumber * lazerprice) << endl;
- cout << "Power Cord \t "<< powernumber << "\t\t\t" << "$" << setprecision(2) << powerprice << "\t\t " << "$" << (powernumber * powerprice) << endl;
- cout << "\t\t Subtotal \t $" << subtotal << endl;
- cout << "\t\t Tax \t\t $" << tax << endl;
- cout << "\t\t Total \t\t $" << total << endl;
- }