fork download
  1. /**********************************************************************************
  2.  * PROGRAMMED BY : DAISY CONTRERAS
  3.  * CLASS : CSC 5
  4.  * SECTION : MW 2:20-5:30PM
  5.  * ASSIGNMENT : CHAPTER 2 QUESTION #8
  6.  **********************************************************************************
  7.  *
  8.  * LIST ITEMS PURCHASED AND COMPUTE THE SUBTOTAL AND TOTAL OF THE PURCHASE
  9.  * ________________________________________________________________________________
  10.  * This program lists the prices of items that are purchased along with the subtotal,
  11.  * sales tax, and the total.
  12.  *_________________________________________________________________________________
  13.  * INPUT
  14.  * price_item : the price of the item
  15.  * subtotal : the subtotal of all of the items that were purchased
  16.  * total : the total of all of the purchased items plus tax
  17.  *
  18.  * OUTPUT
  19.  * price_item : the price of the item
  20.  * subtotal : the subtotal of all of the items that were purchased
  21.  * total : the total of all of the purchased items plus tax
  22.  *
  23.  * *******************************************************************************/
  24. #include <iostream>
  25. using namespace std;
  26.  
  27. int main()
  28. {
  29. float price_item1 = 12.95; //INPUT - price of item 1
  30. float price_item2 = 24.95; //INPUT - price of item 2
  31. float price_item3 = 6.95; //INPUT - price of item 3
  32. float price_item4 = 14.95; //INPUT - price of item 4
  33. float price_item5 = 3.95; //INPUT - price of item 5
  34. float subtotal; //INPUT - subtotal of all items added
  35. float sales_tax; //INPUT - sales tax percentage
  36. float total; //INPUT - total of all items and tax added
  37.  
  38. // Compute the subtotal of all items purchased
  39. subtotal = price_item1 + price_item2 + price_item3 + price_item4 + price_item5;
  40.  
  41. // Define sales tax percentage
  42. sales_tax = 0.06;
  43.  
  44. // Compute the total
  45. total = subtotal + (subtotal * sales_tax);
  46.  
  47. // List the prices of all items
  48. cout << "Price of item 1: " << "$" << price_item1 << endl;
  49. cout << "Price of item 2: " << "$" << price_item2 << endl;
  50. cout << "Price of item 3: " << "$" << price_item3 << endl;
  51. cout << "Price of item 4: " << "$" << price_item4 << endl;
  52. cout << "Price of item 5: " << "$" << price_item5 << endl;
  53.  
  54. // Display the subtotal of the items purchased
  55. cout << "Subtotal: " << "$" << subtotal << endl;
  56.  
  57. // Display the sales tax
  58. cout << "Sales Tax: " << "$" << sales_tax << endl;
  59.  
  60. // Display the total of all items purchased with taxes included
  61. cout << "Total: " << "$" << total << endl;
  62.  
  63. return 0;
  64. }
Success #stdin #stdout 0.01s 5312KB
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: $0.06
Total: $67.575