Write a program that determines the change to be dispensed from a vending machine. An item in the machine can cost between 25 cents and 1 dollar, in
5-cent increments (25, 30, 35, . . . 90, 95, or 100), and the machine accepts only a single dollar bill to pay for the item. For example, a possible sample dialog might be the following:
Enter price of item
(from 25 cents to a dollar, in 5-cent increments):
45
You bought an item for 45 cents and gave me a dollar,
so your change is
2 quarters,
0 dimes, and
1 nickels.
/* 1 Quaters= 25 cents
1 Dimes=10 cents
1 Nickel=5 cents
1 Penny=1 cent
*/
/*Vending Machine accept only 1 dollar coins.so 1 DOLLAR=100 cents*/
import java.util.*;
public class VendingMachine {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input =new Scanner(System.in);
int amount, quarters, dimes, nickels, pennies,exchange;
System.out.println("Enter the price of the(from 25 cents to a dollar, in 5-cent increments): ");
amount=input.nextInt();
exchange= 100-amount;
System.out.println("Amout in Return:"+exchange+"cents");
quarters=exchange/25;
exchange=exchange%25;
dimes=exchange/10;
exchange=exchange%10;
nickels=exchange/5;
exchange=exchange%5;
pennies=exchange;
System.out.println("Quarters:"+quarters+" Dimes:"+dimes+" Nickels:"+nickels+" Pennies:"+pennies);
}
}