Not able to get the answer! Whats wrong with my code?

This is my code for the following problem → HS08TEST Problem - CodeChef
My Code
#include

using namespace std;

int main()
{
int withdraw;
float amount;
cin>>withdraw>>amount;

if(withdraw%5==0)
{
if(withdraw+0.5<=amount&&withdraw!=0)
cout<<amount-withdraw-0.05;
else
cout<<amount;
}
return 0;
}

hey @agnesj0315

there are basically 3 mistakes in your code

  1. your code does not give any output if withdrawal amount in not a multiple of 5.that means you have not used if else loop properly.

2)this line is wrong amount-withdraw-0.05 as you can see in the question the bank charges are 0.5 not 0.05

3)as you can see the output have 2 decimal places,so in order to get that you have to use fixed & setprecision(2),and have to include #include iomanip

here is link to your code modified by me link text

happy coding

@emin3m

Thank you!! It works! :smiley:
Cant believe I didnt notice that extra zero! Oops!