//spooplar 2017
import java.text.DecimalFormat;
public class MakeChange {
public static void main(String[] args) {
int max = 1900;
int min = 100;
int randomNum = (int)(Math.random() * ((max - min) + 1)) + min; //inclusive
int change = 2000 - randomNum;
DecimalFormat format = new DecimalFormat("0.00");
int quarts = change/25;
int dim = change % 25/10;
int nick = change % 25 % 10/5;
int pen = change % 25 % 10 % 5/5;
System.out.println("You gave me twenty buckarooos.");
System.out.println("Your total charge is: $" + format.format(randomNum/100.0) + ", " + "while your total change is: $" + format.format(change/100.0) + ".");
System.out.println("You get these neato coins for your change: ");
System.out.println(quarts + " quarters " + dim + " dimes " + nick + " nickels " + pen + " 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.