Guest User

Untitled

a guest
Feb 9th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.08 KB | None | 0 0
  1. /* Lab 3
  2. Justin Pi
  3. Pi.jp.314@gmail.com
  4. */
  5.  
  6. #include <iomanip>
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. //defines tax rate
  11. #define TAX 0.0875
  12.  
  13. int main()
  14. {
  15.     //Defines each unit price as a constant
  16.     double TVprice = 500;
  17.     double DVDprice = 380;
  18.     double REMOTEprice = 35.20;
  19.     double CDprice = 74.50;
  20.     double AVprice = 1500;
  21.  
  22.     //prompts user for tvs sold $500 per, test data 13
  23.     int TV;
  24.     cout << "How many TVs were sold?"<<endl;
  25.     cin >> TV;
  26.     double TVtotal = TV*TVprice;
  27.    
  28.     //promts user for DVD players sold $380 per, test data 2
  29.     int DVD;
  30.     cout << "How many DVD players were sold?" << endl;
  31.     cin >> DVD;
  32.     double DVDtotal = DVD*DVDprice;
  33.  
  34.     //prompts user for remotes sold $35.20 per, test data 0
  35.     int REMOTE;
  36.     cout << "How many remotes controller units were sold?" << endl;
  37.     cin >> REMOTE;
  38.     double REMOTEtotal = REMOTE*REMOTEprice;
  39.    
  40.     //prompts user for CD players sold $74.50 per, test data 1
  41.     int CD;
  42.     cout << "How many CD players were sold ?" << endl;
  43.     cin >> CD;
  44.     double CDtotal = CD*CDprice;
  45.  
  46.     //prompts user for AV processors sold $1500, test data 21
  47.     int AV;
  48.     cout << "How many AV processors were sold?" << endl;
  49.     cin >> AV;
  50.     double AVtotal = AV*AVprice;
  51.  
  52.     //outputs name, email, lab#
  53.     cout << endl << "Justin Pi" << endl;
  54.     cout << "pi.jp.314@gmail.com" << endl;
  55.     cout << "Lab 3" << endl;
  56.  
  57.     //outputs all prices and total
  58.     cout << fixed << setprecision(2) << endl;
  59.     cout << "QTY    " << "Description           " << "Unit Price        " << "Total Price" << endl;  //1 tab 3 tab 2 tab
  60.     cout << right << TV << "    TVs             " << setw(8) << TVprice << setw(25) << TVtotal << endl;
  61.     cout << right << DVD << "   DVD Players         " << setw(8) << DVDprice << setw(25) << DVDtotal << endl;
  62.     cout << right << REMOTE << "    Remote Controllers      " << setw(8) << REMOTEprice << setw(25) << REMOTEtotal << endl;
  63.     cout << right << CD <<  "   CD Players          " << setw(8) << CDprice << setw(25) << CDtotal << endl;
  64.     cout << right << AV << "    AV Processors           " << setw(8) << AVprice << setw(25) << AVtotal << endl << endl;
  65.  
  66.     //calculates subtotal
  67.     double SUBTOTAL = TVtotal + DVDtotal + REMOTEtotal + CDtotal + AVtotal;
  68.  
  69.     //outputs subtotal, tax and total
  70.     cout << right << setw(30) << "Subtotal" << setw(20) << SUBTOTAL << endl;
  71.     cout << right << setw(30) << "Tax" << setw(20) << SUBTOTAL*TAX << endl;
  72.     cout << right << setw(30) << "Total" << setw(20) << SUBTOTAL + (SUBTOTAL*TAX) << endl;
  73.     return 0;
  74.  
  75. /*  sample output
  76.  
  77. Justin Pi
  78. pi.jp.314@gmail.com
  79. Lab 3
  80.  
  81. QTY     Description                     Unit Price              Total Price
  82. 13      TVs                               500.00                  6500.00
  83. 2       DVD Players                       380.00                   760.00
  84. 0       Remote Controllers                 35.20                     0.00
  85. 1       CD Players                         74.50                    74.50
  86. 21      AV Processors                    1500.00                 31500.00
  87.  
  88.                       Subtotal            38834.50
  89.                            Tax             3398.02
  90.                          Total            42232.52
  91. Press any key to continue . . .
  92.    
  93.    
  94.     */
  95. }
Add Comment
Please, Sign In to add comment