Calculating a Percentage Discount

Hello. I just started learning C++ and need help calculating a percentage discount. I missed the class and my code is based on the example in my book. Although it does the calculation, it does not use a cin statement, which I am not sure what that is. Can someone please show me exactly how the professor wants it, step by step so it is easier to learn? Thank you.

This is the practice assignment I was given:

Ask the user to enter a price (I picked 500). (use a cin statement and store the result in a float)
3. Tell the user what they just entered. (use a cout statement)
4. Apply a 20% discount to the price that the user entered.
5. Tell the user what the discounted price is and how much one would save by applying the discount.
6. Apply a 25% discount to the original price.
7. Tell the user what the discounted price is and how much one would save by applying the discount.

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
 #include <iostream>
using namespace std;

int main()
{
     // variables for regular price, the discount, and sale price
     double regularPrice = 500, discount, salePrice;

     discount = regularPrice * 0.2;
     salePrice = regularPrice - discount;

     cout << "Regular price: $" << regularPrice << endl;
     cout << "Discount amount: $" << discount << endl;
     cout << "Sale Price: $" << salePrice << endl;
     return0;

     discount = regularPrice * 0.25;
     salePrice = regularPrice - discount;

     cout << "Regular price: $" << regularPrice << endl;
     cout << "Discount amount: $" << discount << endl;
     cout << "Sale Price: $" << salePrice << endl;
     return0;
}

closed account (48T7M4Gy)
cin is explained in the following tutorial from this site under standard input which enables you to type in the values of variables required in your program. By the sound of it you should regularly read and use these tutorials.

http://www.cplusplus.com/doc/tutorial/basic_io/
Topic archived. No new replies allowed.