Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.99 KB | None | 0 0
  1. /*
  2.  * CIS 276 Introduction to C/C++ Programming
  3.  * Jim Conley, Professor
  4.  *
  5.  * Student Information (please complete ? below)
  6.  *    Name:        Bill Bruford
  7.  *    RVC Email:    S1113456@student.rockvalleycollege.edu
  8.  * Class Information
  9.  *    Section:      D111
  10.  * Assignment Information
  11.  *                 Program 2  Sales Tax Calc Program - Jan 2016
  12.  *     This program will ask user how much the purchase was before tax.
  13.  *     The program will then compute state sales tax of 4%  and county tax of 2%
  14.  *               and display the results
  15.  *---------------------------------------------------------------------
  16.    
  17.  */
  18.  
  19.  
  20. #include <iostream>
  21. #include <iomanip>
  22. using namespace std;
  23. int main()
  24. {
  25.    // Constants Variable declaration & initialization
  26.    const double TAX_RATE = 0.085;
  27.    const double TIP_RATE = 0.2;
  28.    // Variable for purchase price, State and county taxes, and total taxes
  29.  
  30.    double mealValue;
  31.    double totalBill;
  32.    double totalSalesTax;
  33.    double totalTip;
  34.  
  35.    // INPUT
  36.    cout << "Welcome to the Restaurant Bill calculator!\n";
  37.    cout << "How much was the meal today? ";
  38.    cin >> mealValue;
  39.  
  40.    // PROCESSING SECTION
  41.  
  42.    // Calculate and store the amount of sales tax.
  43.    totalSalesTax = mealValue * TAX_RATE;
  44.  
  45.    // Calculate and store the total tip.
  46.    totalTip = (mealValue + totalSalesTax) * TIP_RATE;
  47.  
  48.    // Calculate and store the amount of the total bill value.
  49.    totalBill = totalSalesTax + mealValue + totalTip;
  50.  
  51.    // OUTPUT  SECTION
  52.    cout << fixed << showpoint << setprecision(2); // formatting of numeric #'s
  53.    cout << left << setw(20) << "Meal:" << setw(5) << "$" << right << setw(8) << mealValue << endl;
  54.    cout << left << setw(20) << "Tax:" << setw(5) << "$" << right << setw(8) << totalSalesTax << endl;
  55.    cout << left << setw(20) << "Tip:" << setw(5) << "$" << right << setw(8) << totalTip << endl;
  56.    cout << left << setw(20) << "Total:" << setw(5) << "$" << right <<  setw(8) << totalBill << endl;
  57.    return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement