// Cenyao Huang CS1A Homework 2, P. 82, #8
/**********************************************************************************************************
* COMPUTE TOTALS AND DISPLAY COSTS
* This program computes the total price, subtotal of the sale, the amount of
* sales tax, and displays the cost of each item purchased by the customer.
*
* Computation uses the formula:
* subtotal = item1 + item2 + item3 + item4 + item5
* total = subtotal + subtotal * (salesTax/100)
*
* Input
* item1 : the price of item1
* item2 : the price of item2
* item3 : the price of item3
* item4 : the price of item4
* item5 : the price of item5
* salesTax: the amount of sales tax
* subtotal : the value of the sum of item1, item2, item3, item4, and item5
*
* Output
* item1 : the price of item1
* item2 : the price of item2
* item3 : the price of item3
* item4 : the price of item4
* item5 : the price of item5
* salesTax: the amount of sales tax
* subtotal : the value of the sum of item1, item2, item3, item4, and item5
* total : the value of the subtotal multiplied by salesTax, then added to the subtotal
*
********************************************************************************************************/
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
double subtotal; // define variables
double total;
double item1 = 12.95, item2 = 24.95, item3 = 6.95, item4 = 14.95, item5 = 3.95;
double salesTax = 6;
subtotal = item1 + item2 + item3 + item4 + item5; //calculate item costs and final total
total = subtotal + subtotal * (salesTax/100);
cout << "item1 = $" << item1 << endl << "item2 = $" << item2 << endl; //display item prices
cout << "item3 = $" << item3 << endl << "item4 = $" << item4 << endl;
cout << "item5 = $" << item5 << endl;
cout << "subtotal = $" << subtotal << endl; //display subtotal, sales tax, and total
cout << "sales tax = " << salesTax << "%" << endl;
cout << "total = $" << fixed << setprecision(2) << total << endl;
return 0;
}