MakeChange

# MakeChange - /Step 1 change = console.nextInt/Step 2...

This preview shows pages 1–2. Sign up to view the full content.

//************************************************************ // Author: D. S. Malik // // Program Make Change: Given any amount of change expressed // in cents, this program computes the number of half-dollars, // quarters, dimes, nickels, and pennies to be returned, // returning as many half-dollars as possible, then quarters, // dimes, nickels, and pennies, in that order. //************************************************************ / import java.util.*; i public class MakeChange { static Scanner console = new Scanner(System.in); static final int HALFDOLLAR = 50; static final int QUARTER = 25; static final int DIME = 10; static final int NICKEL = 5; public static void main (String[] args) { //declare variables int change; //Statements: Step 1 - Step 12 System.out.print("Enter the change in cents: ");

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //Step 1 change = console.nextInt(); //Step 2 System.out.println(); System.out.println("The change you entered is " + change); //Step 3 System.out.println("The number of half dollars " + "to be returned is " + change / HALFDOLLAR); //Step 4 change = change % HALFDOLLAR; //Step 5 System.out.println("The number of quarters to be " + "returned is " + change / QUARTER); //Step 6 change = change % QUARTER; //Step 7 System.out.println("The number of dimes to be " + "returned is " + change / DIME); //Step 8 change = change % DIME; //Step 9 System.out.println("The number of nickels to be " + "returned is " + change / NICKEL); //Step 10 change = change % NICKEL; //Step 11 System.out.println("The number of pennies to be " + "returned is " + change); //Step 12 } }...
View Full Document

## This note was uploaded on 06/17/2011 for the course COMP 2301 taught by Professor Staff during the Spring '10 term at Kennesaw.

### Page1 / 2

MakeChange - /Step 1 change = console.nextInt/Step 2...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online