0

thier is sth wrong in this code

 double groceries;     double vegetables;     double beverage; cout<<" Enter the price of groceries:  \n"; cin>>groceries; cout<<" Enter the price of vegetable:  \n"; cin>>vegetables; cout<<" Enter the price of beverage:   \n"; cin>>beverage; double amount_without_discount= groceries + vegetables + beverage ; double amount_with_discount = amount_without_discount – (amount_without_discount * 0.1); cout<<"Amount without discount = \n "<<amount_without_discount; cout<<"Amount with discount = \n"<<amount_with_discount;

15th Apr 2020, 7:12 AM
Shahed
Shahed - avatar
2 Answers
+ 3
You have invalid characters in that code, which prevents the code from being compiled. And you should replace the '–' character with a hyphen '-' in the line where you calculate the discounted amount. * Replace this line double amount_with_discount = amount_without_discount – (amount_without_discount * 0.1); * With this 👇 double amount_with_discount = amount_without_discount - (amount_without_discount * 0.1); Notice the use of hyphen on second example. * You can also opt to do this instead. double amount_with_discount = amount_without_discount * 0.9;
15th Apr 2020, 7:33 AM
Ipang
0
You can actually make your code easier to read by doing this: double groceries, vegetables, beverage;
15th Apr 2020, 12:01 PM
SmallNinja2006
SmallNinja2006 - avatar