We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
you might be getting error for 4th case...this is because u need to calculate the roundoff of each component(tax and tip) individually instead of calculating roundoff after adding them
example:
tip=2.59=3(after roundoff)
tax=4.67=5(after roundoff)
so total=8
now ur mistaki is
total=tip+tax=2.59+4.67=7.26=7(after roundoff)
Day 2: Operators
You are viewing a single comment's thread. Return to all comments →
you might be getting error for 4th case...this is because u need to calculate the roundoff of each component(tax and tip) individually instead of calculating roundoff after adding them example: tip=2.59=3(after roundoff) tax=4.67=5(after roundoff) so total=8
now ur mistaki is total=tip+tax=2.59+4.67=7.26=7(after roundoff)
try out this: if( (tip + 0.5) >= (int(tip) + 1) ) cout << int(tip)+1; else cout << int(tip);