This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by NishqaSharma
about 9 years

why can i not write tip = 15/100 ?

when i wrote tax = 6.75/100 in step 3, it got converted to 0.0675 on it’s own

however, when i wrote tip = 15/100, it showed me an error, saying “looks like tip has been assigned as zero.”

why did this difference come in? please tell me. :)

Answer 54f663d776b8fe42380007d4

1 vote

Permalink

integers cannot represent decimals and int / int results in an int, 15 / 100 is thus 0 convert one of the ints to float before the division occurs to get a float result

points
Submitted by Jonatan
about 9 years

1 comments

NishqaSharma about 9 years

Hey thanks a lot! It really helped.

Answer 5504c657e39efedc4b005338

0 votes

Permalink

Try 15.0/100 instead. I got the same error message before.

points
Submitted by Chris Kubik
about 9 years