Question: NOTE: please explain each step because I'm a beginner still don't know much about coding, please. NOTE: please explain each step because I'm a beginner
NOTE: please explain each step because I'm a beginner still don't know much about coding, please.
NOTE: please explain each step because I'm a beginner still don't know much about coding, please.
NOTE: please explain each step because I'm a beginner still don't know much about coding, please.
Chapter 4:
Note 1: Read and understand all the given text of the assignment, then start writing the algorithm and test it correctness, and then, translate the algorithm to Java statements and type it into Java complier editor.
Suppose a person can buy a chocolate bar from the vending machine for $1 each. Inside every chocolate bar is a coupon. A person can redeem 6 coupons for one chocolate bar from the machine. This means that once a person has started buying chocolate bars from the machine, he/she always has some coupons. A person would like to know how many chocolate bars can be bought, if a person starts with N dollars and always redeem coupons, if he/she has enough for an additional chocolate bar.
For example:
1. With 6 dollars a person could buy 7 chocolate bars after purchasing 6 bars giving him/her 6 coupons and then redeeming the 6 coupons for one bar. This would leave him/her with one extra coupon. Thus, will have 7 chocolate bars and still have one coupon leftover.
2. For 11 dollars, a person can have 13 chocolate bars and still have one coupon leftover.
3. For 12 dollars, a person can have 14 chocolate bars and have two coupons leftover.
Write a complete Java program that prompts a buyer to input a value for N dollars and displays/outputs how many chocolate bars a person can get and how many coupons would have leftover.
Implementation Note:
Use a loop that continues to redeem coupons as long as there are enough to get at least one chocolate bar.
the output should be like the following:
the output should be like the following:
----jGRASP exec: java ChocolateCoupons How much money can you spend on chocolate bars? 56 After redeeming coupons, you would have 1 leftover coupons and can purchase a total of 67 chocolate bars. ----jGRASP: operation complete.
Sample2:
----jGRASP exec: java ChocolateCoupons
How much money can you spend on chocolate bars?
7
After redeeming coupons, you would have 2 leftover coupons and can purchase a total of 8 chocolate bars.
----jGRASP: operation complete.
NOTE: please explain each step because I'm a beginner still don't know much about coding, please.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
