Help I still don't know what he's asking.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
Create a CPP file named lab2 in Visual C++ with the source file containing the following lines.
//**************************************************************
//
// File Name: lab2.cpp
//
// A Program to calculate the sales tax and final sales
// price of items in a retail environment
//
// Programmer: “Your Name Goes Here”
//
// Date Written: today’s date
//
// Date last revised:
//
//**************************************************************
#include <iostream> // need cin, cout and endl
#include <iomanip> // need setprecision
using namespace std;
#define pause system(“pause”) // stop the screen from scrolling
#define cls system(“cls”) // clear the screen
const double SALES_TAX_RATE = 0.0875; // current sales tax rate
// in Erie County NY, USA
int main ()
{
double price, // price of the item
salesTax, // sales tax on the item
finalPrice; // price of the item plus sales tax
// ask user for item price
cout << "Please enter the current price of the item $" ;
// grab the price info
cin >> price;
cout << endl ; // skip a line for readability
pause; // let the user read the screen
cls; // clear the screen
// Now do the calculations
salesTax = price * SALES_TAX_RATE;
finalPrice = price + salesTax;
// Now do some pretty printing of the results
cout << "The price of the item was " << price
<< "\n\n\n";
cout << "The sales tax on the item was "
<< salesTax << "\n\n";
cout << "The price including the sales tax for the item was ";
cout << finalPrice << "\n" << endl;
return 0;
}
|
1)
note if you are using a MAC IDE:
A) DO NOT USE
#define pause system(“pause”) // stop the screen from scrolling
INSTEAD USE:
cout << "\nPress the enter key to continue.\n";
cin.get();
IN PLACE OF THE
pause;
LINE
B) DO NOT USE
#define cls system(“cls”) // clear the screen
INSTEAD USE:
for(int k = 0; k < 25; k++)
cout << endl;
IN PLACE OF THE
cls;
LINE
END OF THE MAC SECTION DISREGARD IF NOT USING A MAC
2) Build the executable file. Locate and fix any errors and rebuild the executable.
3) Run the program using the input value of 1.9.
4) Rerun the program trying other values.
5) Notice the output does not quite look like a “money” value.
6) Modify the program to include a “$” output to pretty up the output.
7) Notice that the output still does not look like “money” because $1.9 does not look right but $1.90 does.
8) Add lines of code to have the money values printed with 2 decimal places.(note see page 114 in your book)
10) Rerun the program, now notice how the output lines are “pretty”.