Change Program of Peter's

/** * This program prints things * Author: Peter.T * created: 9/6/2017 */ import java.util.*; public class Changes//class header { Scanner scan = new Scanner(System.in); public static void main(String[] args) { int max = 1900; int min = 100; int randomNum = (int)(Math.random() * ((max - min) + 1)) + min; //inclusive double myNum = randomNum/100.0; double change = 20-myNum; System.out.println("Random Number: " + myNum); System.out.println("change " + change); int quarters = (int)(change/0.25); change = change%0.25; System.out.println("quarters: " + quarters); int dimes = (int)(change/0.1); change = change%0.1; System.out.println("dimes: " + dimes); int nickles = (int)(change/0.05); change = change%0.05; System.out.println("nickles: " + nickles); int pennies = (int)(change/0.01); System.out.println("pennies: " + pennies); } }

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.