Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Lab 3
- Justin Pi
- Pi.jp.314@gmail.com
- */
- #include <iomanip>
- #include <iostream>
- using namespace std;
- //defines tax rate
- #define TAX 0.0875
- int main()
- {
- //Defines each unit price as a constant
- double TVprice = 500;
- double DVDprice = 380;
- double REMOTEprice = 35.20;
- double CDprice = 74.50;
- double AVprice = 1500;
- //prompts user for tvs sold $500 per, test data 13
- int TV;
- cout << "How many TVs were sold?"<<endl;
- cin >> TV;
- double TVtotal = TV*TVprice;
- //promts user for DVD players sold $380 per, test data 2
- int DVD;
- cout << "How many DVD players were sold?" << endl;
- cin >> DVD;
- double DVDtotal = DVD*DVDprice;
- //prompts user for remotes sold $35.20 per, test data 0
- int REMOTE;
- cout << "How many remotes controller units were sold?" << endl;
- cin >> REMOTE;
- double REMOTEtotal = REMOTE*REMOTEprice;
- //prompts user for CD players sold $74.50 per, test data 1
- int CD;
- cout << "How many CD players were sold ?" << endl;
- cin >> CD;
- double CDtotal = CD*CDprice;
- //prompts user for AV processors sold $1500, test data 21
- int AV;
- cout << "How many AV processors were sold?" << endl;
- cin >> AV;
- double AVtotal = AV*AVprice;
- //outputs name, email, lab#
- cout << endl << "Justin Pi" << endl;
- cout << "pi.jp.314@gmail.com" << endl;
- cout << "Lab 3" << endl;
- //outputs all prices and total
- cout << fixed << setprecision(2) << endl;
- cout << "QTY " << "Description " << "Unit Price " << "Total Price" << endl; //1 tab 3 tab 2 tab
- cout << right << TV << " TVs " << setw(8) << TVprice << setw(25) << TVtotal << endl;
- cout << right << DVD << " DVD Players " << setw(8) << DVDprice << setw(25) << DVDtotal << endl;
- cout << right << REMOTE << " Remote Controllers " << setw(8) << REMOTEprice << setw(25) << REMOTEtotal << endl;
- cout << right << CD << " CD Players " << setw(8) << CDprice << setw(25) << CDtotal << endl;
- cout << right << AV << " AV Processors " << setw(8) << AVprice << setw(25) << AVtotal << endl << endl;
- //calculates subtotal
- double SUBTOTAL = TVtotal + DVDtotal + REMOTEtotal + CDtotal + AVtotal;
- //outputs subtotal, tax and total
- cout << right << setw(30) << "Subtotal" << setw(20) << SUBTOTAL << endl;
- cout << right << setw(30) << "Tax" << setw(20) << SUBTOTAL*TAX << endl;
- cout << right << setw(30) << "Total" << setw(20) << SUBTOTAL + (SUBTOTAL*TAX) << endl;
- return 0;
- /* sample output
- Justin Pi
- pi.jp.314@gmail.com
- Lab 3
- QTY Description Unit Price Total Price
- 13 TVs 500.00 6500.00
- 2 DVD Players 380.00 760.00
- 0 Remote Controllers 35.20 0.00
- 1 CD Players 74.50 74.50
- 21 AV Processors 1500.00 31500.00
- Subtotal 38834.50
- Tax 3398.02
- Total 42232.52
- Press any key to continue . . .
- */
- }
Add Comment
Please, Sign In to add comment