public class VendingMachine {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int amount, originalAmount,
quarters, dimes, nickels, change, endChange, quarter, dime, nickel, money;
System.out.println("Enter price of item");
System.out.println("from 25 cents to a dollar, in 5-cent increments:");
amount = keyboard.nextInt( );
if (amount < 25);
System.out.println("You must enter an amout over 25 cents.");
if (amount > 100);
System.out.println("You must enter an amount less than 100.");
if ((amount < 25) || (amount > 100));
System.exit(0);
if (amount % 5 == 0);
System.out.println("You must enter in increments of 5");
if ((amount>25) || (amount<100));
originalAmount = amount ;
quarters = ((100-amount) / 25);
amount= (100-amount) % 25;
dimes = amount / 10;
amount = amount % 10;
nickels = amount / 5;
amount = amount % 5;
System.out.println("You bought an item for " + originalAmount + " cents and gave me a dollar, so your change is:");
System.out.println(quarters + " quarters,");
System.out.println(dimes + " dimes,");
System.out.println(nickels + " nickels");
}
}
the problem im having is the program doesnt work and it just displays the two error messages
You must enter an amout over 25 cents.
You must enter an amount less than 100.

New Topic/Question
Reply



MultiQuote



|