1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
//Declaring The Quantity
int tvquan, dvdquan, remotequan, cdplaquan,
avquan;
//Declaring The Prices of Each Items
const double tvprice = 500.00,
dvdprice = 380.00,
remoteprice = 35.20,
cdplaprice = 75.50,
avprice = 1500.00;
#define const taxrate = 0.0875;
//Declaring The Total Amount (This is where the input of quantity * the prices goes)
double tvtotal, dvdtotal, remotetotal, cdtotal,
avtotal, subtotal, tax, total;
//Inputing
cout << "How many TVs were sold? ";
cin >> tvquan;
cout << "How many DVD players were sold? ";
cin >> dvdquan;
cout << "How many Remote Controllers units were sold? ";
cin >> remotequan;
cout << "How many CD Players were sold? ";
cin >> cdplaquan;
cout << "How many AV Processors were sold? ";
cin >> avquan;
//This computes the tax, total of each quantity that was input, and the total of all items together combined
tvtotal = tvquan * tvprice;
dvdtotal = dvdquan * dvdprice;
remotetotal = remotequan * remoteprice;
cdtotal = cdplaquan * cdplaprice;
avtotal = avquan * avprice;
subtotal = tvtotal + dvdtotal + remotetotal + cdtotal + avtotal;
tax = subtotal * taxrate;
total = tax + subtotal;
//Output The Total of all Items That were Input in the Variables
cout << setprecision(2) << fixed; //
cout << "\n\nQTY " << "Description" << " Unit Price " << "Total Price" << endl;
cout << right << setw(2) << tvquan << right << setw(15) << "TV" << right << setw(20) << "$" << tvprice << right << setw(15) << "$" << tvtotal << endl;
cout << right << setw(2) << dvdquan << right << setw(16) << "DVD" << right << setw(19) << "$" << dvdprice << right << setw(15) << "$" << dvdtotal << endl;
cout << right << setw(2) << remotequan << right << setw(30) << "REMOTE CONTROLLER" << right << setw(5) << "$" << remoteprice << right << setw(16) << "$" << remotetotal << endl;
cout << right << setw(2) << cdplaquan << right << setw(22) << "CD PLAYER" << right << setw(13) << "$" << cdplaprice << right << setw(16) << "$" << cdtotal << endl;
cout << right << setw(2) << avquan << right << setw(25) << "AV PROCESSOR" << right << setw(10) << "$" << avprice << right << setw(14) << "$" << avtotal << endl << endl;
cout << right << setw(44) << "Subtotal: $" << subtotal << endl;
cout << right << setw(44) << "Tax: $" << tax << endl;
cout << right << setw(44) << "Total: $" << total << endl << endl;
|