Question: Write a Java program named Planet that simulates a vending machine. All items in the machine cost between 25 cents and one- dollar, and are
Write a Java program named Planet that simulates a vending machine. All items in the machine cost between 25 cents and one- dollar, and are in integrals of 5 cents. So an item could cost 55, 75, 80, etc. but not 52, 101, 20, 44, etc. Ask the user for the cost of the item. The user purchases the item with a one-dollar bill. The output should be the number of quarters, dimes, and nickels in change. Add data validation. If the user puts in an invalid cost for the item (less than 25 cents, over one dollar, or a number not divisible by 5, indicate so). See sample output below 
Change (I am showing you only a few sample runs - make certain to test yours completely) Run #1: How much did the vending machine item cost? 100 No change! Run #2: How much did the vending machine item cost? 72 Not a valid cost. Must be between 25 and 100 in increments of 5 Run #3: How much did the vending machine item cost? 50 Your change is 2 quarters Run #4: How much did the vending machine item cost? 35 Your change is 6 2 quarters 1 dimes 1 nickels
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
