fork download
  1. //Amari Mosley CSC5 Chapter 2, P. 81, #8
  2. //
  3. /**************************************************************
  4.  *
  5.  * TOTAL PURCHASE
  6.  * ____________________________________________________________
  7.  * This program calculates the subtotal of the sale, the amount
  8.   of sales tax, and the total.
  9.  
  10.  * Computation is based on the following formulas:
  11.  * Subtotal = Item1 + Item2 +Item3 + Item4 + Item5
  12.   TotalTax = Subtotal * TaxRate
  13.   Total = Subtotal + TotalTax
  14.  * ____________________________________________________________
  15.  * INPUT
  16.  * Item1, Item2, Item3, Item4, Item5 : The five items the customer is buying
  17.  *
  18.  * TaxRate : The base tax rate percentage
  19.  
  20.  * OUTPUT
  21.  * SubTotal : Sum of all 5 items
  22. TotalTax : Total amount of tax being payed
  23. Total : Total amount of money being paid (sum of SubTotal and TotalTax)
  24.  *
  25.  **************************************************************/
  26. #include <iostream>
  27. #include <iomanip>
  28. using namespace std;
  29.  
  30. // Defining Main Function
  31. int main()
  32.  
  33. {
  34. // Defining double Variables
  35. double Item1, Item2, Item3, Item4, Item5;
  36. double TaxRate;
  37. double SubTotal, TotalTax, Total;
  38.  
  39. // Assigning Values of Variables TotalSales and EastCoast
  40. Item1 = 12.95, Item2 = 24.95, Item3 = 6.95, Item4 = 14.95, Item5 = 3.95;
  41. TaxRate = 0.06;
  42.  
  43. //Computing SubTotal
  44. SubTotal = Item1 + Item2 + Item3 + Item4 + Item5;
  45.  
  46. //Computing TotalTax
  47. TotalTax = SubTotal * TaxRate;
  48.  
  49. //Compute Final Total
  50. Total = SubTotal + TotalTax;
  51.  
  52. cout << "Price of item 1: $" << Item1 << endl;
  53. cout << "Price of item 2: $" << Item2 << endl;
  54. cout << "Price of item 3: $" << Item3 << endl;
  55. cout << "Price of item 4: $" << Item4 << endl;
  56. cout << "Price of item 5: $" << Item5 << endl;
  57. cout << "Subtotal: $" << SubTotal << endl;
  58. cout << "Sales tax: $" << TotalTax << endl;
  59. cout << "Total: $" << Total << endl;
  60.  
  61. return 0;
  62. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Price of item 1: $12.95
Price of item 2: $24.95
Price of item 3: $6.95
Price of item 4: $14.95
Price of item 5: $3.95
Subtotal: $63.75
Sales tax: $3.825
Total: $67.575