"write a program that asks the user to enter the price of an item and rate of discount. If discount is 9%, display the final cost of item"
What message do I display if its not 9%? Algorithms btw
if the original price is $100, the final cost is $91.
To write a program that asks the user to enter the price of an item and the rate of discount, and then displays the final cost of the item if the discount is 9%, you can follow these steps:
1. Ask the user to enter the price of the item and store it in a variable, let's say `price`.
2. Ask the user to enter the rate of discount and store it in a variable, let's say `discount_rate`.
3. Calculate the discount amount by multiplying `price` with `discount_rate` divided by 100, and store it in a variable, let's say `discount_amount`.
4. Calculate the final cost of the item by subtracting `discount_amount` from `price`, and store it in a variable, let's say `final_cost`.
5. Use an `if` statement to check if the `discount_rate` is equal to 9%.
6. If the condition is true, display the final cost of the item using a suitable message.
7. If the condition is false, display a message stating that the discount rate is not 9%.
Here's the algorithm in pseudocode:
```
1. Read the price of the item from the user and store it in a variable, price.
2. Read the discount rate from the user and store it in a variable, discount_rate.
3. Calculate the discount amount by multiplying price with discount_rate divided by 100 and store it in a variable, discount_amount.
4. Calculate the final cost of the item by subtracting discount_amount from price and store it in a variable, final_cost.
5. If discount_rate is equal to 9%, then
6. Display "The final cost of the item is " followed by final_cost.
7. Otherwise,
8. Display "The discount rate is not 9%.".
```
You can implement this algorithm in the programming language of your choice, such as Python or JavaScript, to get the desired output.