Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A bill is rupees. A tip of percent is added, and friends share the total equally. Write a program that reads these three numbers and shows what each person pays.
Work out the tip, add it to the bill, then divide by the number of friends.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Tip, then total, then the share.
tip = bill * tip_percent / 100, which is .total = bill + tip, which is .each = total / friends, which is .Check. . ✓
Answer: rupees for each person.
Log in to join the discussion.
Loading…