/****************************************************************** * Lab 1: Vending Machine Change * * Programmer: Insert your name * * Due Date: Friday, September 5, 2008 * * COMP110-003, Fall 2008 Instructor: Luv Kohli * * Pledge: I have neither given nor received unauthorized aid * on this program. (Signature on file) * * Description: This program outputs a combination of coins that * equals the amount of money (from 1 to 99 cents) * the user inputs. * * Input: One whole number from 1 to 99 * * Output: A combination of coins that equals the amount of money * specified in the input * ******************************************************************/ import java.util.*; public class VendingMachine { public static void main(String[] args) { int amount, originalAmount, quarters, dimes, nickels, pennies; System.out.println("Enter a whole number from 1 to 99."); System.out.println("I will output a combination of coins"); System.out.println("that equals that amount of change."); Scanner keyboard = new Scanner(System.in); // read the amount into the variable amount amount = keyboard.nextInt(); originalAmount = amount; quarters = amount / 25; amount = amount % 25; dimes = amount / 10; amount = amount % 10; nickels = amount / 5; amount = amount % 5; pennies = amount; System.out.println(originalAmount + " cents in coins can be given as:"); System.out.println(quarters + " quarters"); System.out.println(dimes + " dimes"); System.out.println(nickels + " nickels and"); System.out.println(pennies + " pennies"); } }