Basically I am a complete beginner in C++ and I am facing a problem in updating the value of a variable in my code. Basically the code is to apply discount, so I am trying to update the value of bill
but it is not working, where am I going wrong?
This is my entire code:
#include <iostream>
using namespace std;
int main()
{
float bill;
cout << "Enter bill amount: ";
cin >> bill;
float discount;
if (bill < 100) {
cout << "No discount applicable!" << endl;
cout << "The bill is " << bill;
}
else if (bill >= 100 && bill < 500) {
cout << "Congrats! A discount of 20% is applicable!" << endl;
discount = 20 / 100;
bill = bill - bill * discount;
cout << "Final bill is " << bill << endl;
}
else if (bill >= 500) {
cout << "Congrats! A discount of 30% is applicable!" << endl;
discount = 30 / 100;
bill = bill - bill * discount;
cout << "Final bill is " << bill << endl;
}
}
Also any other suggestions regarding the code will be appreciated!