/**
* Figures out change
*
* @author Charlie
* @version 1
*/
public class Change
{ 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;
System.out.println("Random Number is : " + myNum);
double change;
change = 20 - myNum;
System.out.println("Change : " + change);
double quarters;
double dimes;
double nickels;
double pennies;
quarters = change / 0.25;
double newchange = change % 0.25;
System.out.println("Quarters :" + quarters);
dimes = newchange / 0.10;
double newchange2 = newchange % 0.10;
System.out.println("Dimes : " + dimes);
nickels = newchange2 / 0.05;
double newchange3 = newchange2 % 0.05;
System.out.println("Nickels : " + nickels);
pennies = newchange3 / 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.