fork download
  1. //Andrew Alspaugh CSC5 Chapter 2, P. 82, #8
  2. //
  3. /*******************************************************************************
  4.  *
  5.  * Calculate Subtotal, Sales Tax, and Total
  6.  * ____________________________________________________________________________
  7.  * This program checks the prices of each item and uses those prices to compute
  8.  * the subtotal, sales tax, and total
  9.  *
  10.  * Formula for computarion is:
  11.  * total = sales tax + subtotal
  12.  * sales tax = subtotal x .06
  13.  * subtotal = price of all recieved prices
  14.  * ___________________________________________________________________________
  15.  * INPUT
  16.  * p1 : item price
  17.  * p2 : item price
  18.  * p3 : item price
  19.  * p4 : item price
  20.  * p5 : item price
  21.  *
  22.  * OUTPUT
  23.  * subtotal :total price of items
  24.  * salesTax :subtotal x .06
  25.  * Total :subtotal + salesTax
  26.  *
  27.  ******************************************************************************/
  28. #include <iostream>
  29. using namespace std;
  30.  
  31. int main() {
  32.  
  33. float
  34. p1 = 12.95, //INPUT-ITEM PRICE
  35. p2 = 24.95, //INPUT-ITEM PRICE
  36. p3 = 6.95, //INPUT-ITEM PRICE
  37. p4 = 14.95, //INPUT-ITEM PRICE
  38. p5 = 3.95, //INPUT-ITEM PRICE
  39.  
  40. //ADD ALL FOR SUBTOTAL
  41. subtotal = p1 + p2 + p3 + p4 +p5, //OUTPUT total price of items
  42. // SUB TIMES TAX =SALES TAX
  43. salesTax = subtotal * .6, //OUTPUT subtotal x .06
  44. // TOTAL = subtotal + SALES TAX
  45. Total = subtotal + salesTax; //OUTPUT subtotal + salesTax
  46.  
  47. cout << p1 << ", " << p2 << ", " << p3 << ", " << p4 << ", " << p5 << endl;
  48. cout << subtotal << endl;
  49. cout << salesTax << endl;
  50. cout << Total;
  51. return 0;
  52.  
  53. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
12.95, 24.95, 6.95, 14.95, 3.95
63.75
38.25
102