This preview shows page 1. Sign up to view the full content.
Unformatted text preview: System.out.println ("Please enter the price of items in cents (25-100): "); price = keyboard.nextInt(); p //Calculate the change first, and then I used % to find the remainder change = DOLLAR - price; numQuarters = change/QUARTER; modChange = change%QUARTER; numDimes = modChange/DIME; modChange = modChange%DIME; numNickles = modChange/NICKLE; modChange = modChange%NICKLE; numPennies = modChange/PENNIE; n //Print the results System.out.println("You bought an item for " + price + " cents and gave me a dollar."); System.out.println("Your change (" + change + " cents) is "); System.out.println("Quarters: " + numQuarters); System.out.println("Dimes: " + numDimes); System.out.println("Nickles: " + numNickles); System.out.println("Pennies: " + numPennies); S } }...
View Full Document
This note was uploaded on 03/15/2010 for the course ITP 109x taught by Professor Trinagregory during the Spring '08 term at USC.
- Spring '08