Question by tambourine: simple java program “bakesale”?
im trying to make a noob program that
asks how much money they have (lets say 10.33)
tells them how many they can buy with that money (50c each)
lists how much change they get back
the problem i’m having is in my version, the program tells the user they can buy fractions of brownies (like 1.42 brownies) and I don’t want it to do that.
I end up taking the total amount they have, minus what they can buy, multiplied by price and it equals zero. If someone can point me in the right direction how to make the number they can buy a whole number would be great
Answer by pyr0
use the % (modulus). It gives remainders of a number divided by another.
Give your answer to this question below!