/**
* Converts Temperature
*
* Sejin Park
* 09/07/17
*/
import java.util.*;
public class ChangeFor20
{
public static void main(String args[]){
int max = 1800;
int min = 100;
int randomNum = (int)(Math.random() * ((max - min) + 1)) + min; //inclusive
randomNum = 1064;
double myNum = randomNum/100.0;
System.out.println("Random Number: " + myNum);
double changeNum = 20 - myNum;
System.out.println("Change: " + changeNum);
int newChange = (randomNum % 25);
int quarters = (randomNum) / 25;
System.out.println("Quarters: " + quarters);
int dimes = (newChange)/10;
newChange = newChange % 10;
System.out.println("Dimes: " + dimes);
int nickels = (newChange)/5;
newChange = newChange % 5;
System.out.println("Nickels: " + nickels);
int pennies = (newChange)/1;
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.