I need help Microsoft Visual C++

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”.
Last edited on
Which bit? There are 10 individual instructions there. Which one(s) don't you understand?
I need to calculate the sales tax and final sales by using this program. I don't understand it's on the bottom of what to do
Last edited on
Sales tax is calculated at line 47. What don't you understand about that?

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

I need to calculate the sales tax and final sales by using this program. I don't understand it's on the bottom of what to do

Um, I don't see it anywhere in the list of instructions for what to do.

As AbstractionAnon says, the code your teacher has already supplied to you seems to be doing the calculation.
Sorry I'm just starting out. I'm just having trouble with the program
Could you be a bit more specific, please?

Have you followed step 1 yet? Have you created a CPP file that contains the code that your teacher has given you?
Yes
So which of the other 8 parts of the exercise are you having trouble with?

We can't read your mind! We can't help you unless you're specific about what you need help with.
Last edited on
Parts 2-8 I don't know how to format the values correctly or how to build an exe file?
Step 2) Have you tried to compile the program? Do you get any errors?
If so, what are they?
All I did was paste this in the program. It's not doing anything.
Have you saved the file?

Have you tried to compile it?
It looks like your instructor is getting you to do a very basic exercise of compiling and running a simple program. In which case you need to figure out how to get the code into Visual C++, compile the code, and then run it.
Topic archived. No new replies allowed.