Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * CIS 276 Introduction to C/C++ Programming
- * Jim Conley, Professor
- *
- * Student Information (please complete ? below)
- * Name: Bill Bruford
- * RVC Email: S1113456@student.rockvalleycollege.edu
- * Class Information
- * Section: D111
- * Assignment Information
- * Program 2 Sales Tax Calc Program - Jan 2016
- * This program will ask user how much the purchase was before tax.
- * The program will then compute state sales tax of 4% and county tax of 2%
- * and display the results
- *---------------------------------------------------------------------
- */
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- // Constants Variable declaration & initialization
- const double TAX_RATE = 0.085;
- const double TIP_RATE = 0.2;
- // Variable for purchase price, State and county taxes, and total taxes
- double mealValue;
- double totalBill;
- double totalSalesTax;
- double totalTip;
- // INPUT
- cout << "Welcome to the Restaurant Bill calculator!\n";
- cout << "How much was the meal today? ";
- cin >> mealValue;
- // PROCESSING SECTION
- // Calculate and store the amount of sales tax.
- totalSalesTax = mealValue * TAX_RATE;
- // Calculate and store the total tip.
- totalTip = (mealValue + totalSalesTax) * TIP_RATE;
- // Calculate and store the amount of the total bill value.
- totalBill = totalSalesTax + mealValue + totalTip;
- // OUTPUT SECTION
- cout << fixed << showpoint << setprecision(2); // formatting of numeric #'s
- cout << left << setw(20) << "Meal:" << setw(5) << "$" << right << setw(8) << mealValue << endl;
- cout << left << setw(20) << "Tax:" << setw(5) << "$" << right << setw(8) << totalSalesTax << endl;
- cout << left << setw(20) << "Tip:" << setw(5) << "$" << right << setw(8) << totalTip << endl;
- cout << left << setw(20) << "Total:" << setw(5) << "$" << right << setw(8) << totalBill << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement