Computer Science, asked by srinidhitr2005, 9 months ago

Write a program in java to do the following: input number of chocolates purchased in a variable and the price fo each chocolate in another variable - Calculate the cost (price*quantity) - If the cost is greater than 50, a discount of 2% is given on the cost and total cost is same as the cost - Finally display number of chocolates purchased, quantity, cost, total cost and discount PLEASE HELP ME

Answers

Answered by nicholfsfa
0

Input :   money = 16, price = 2, wrap = 2

Output :   15

Price of a chocolate is 2. You can buy 8 chocolates from

amount 16. You can return 8 wrappers back and get 4 more

chocolates. Then you can return 4 wrappers and get 2 more

chocolates. Finally you can return 2 wrappers to get 1

more chocolate.

Input :   money = 15, price = 1, wrap = 3

Output :   22

We buy and eat 15 chocolates

We return 15 wrappers and get 5 more chocolates.

We return 3 wrappers, get 1 chocolate and eat it

(keep 2 wrappers). Now we have 3 wrappers. Return

3 and get 1 more chocolate.

So total chocolates = 15 + 5 + 1 + 1

Input :  money = 20, price = 3, wrap = 5

Output :   7

Similar questions