Make Change D

/** * Write a description of class MakeChange here. * * @au * thor (your name) * @version (a version number or a date) */ import java.util.*; public class MakeChange { public static void main(String[] args) { int max = 1900; int min = 100; int total = 20; int randomNum = (int)(Math.random() * ((max - min) + 1)) + min; //inclusive double myNum = randomNum/100.0; double change = (total - myNum); double quarters = change/.25; change = change%25; double dimes = 0; dimes = (change/.10); change = change%10; double nickels = 0; nickels = (change/.05); nickels = change%5; double cents = 0; cents = (change/.01); cents = change%5; System.out.println("Random Number: " + myNum); System.out.println("Change: " + change); System.out.println("Quarters: " + quarters+ "Dimes: " + dimes+ "Nickels" +nickels+ "Cents:" + cents); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.