forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWithdrawal.java
More file actions
29 lines (20 loc) · 786 Bytes
/
Withdrawal.java
File metadata and controls
29 lines (20 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
public class Withdrawal
{
public static void main(String args[])
{
int withdrawal = 137;
int twenties = withdrawal / 20;
System.out.println("$20: " + twenties);
int remainder = withdrawal - (20 * twenties);
//System.out.println(remainder + " left to go.");
int tens = remainder / 10;
remainder = withdrawal - (twenties * 20) - (tens * 10);
System.out.println("$10: " + tens);
//System.out.println(remainder + " left to go.");
int fives = remainder / 5;
remainder = withdrawal - (twenties * 20) - (tens * 10) - (fives * 5);
System.out.println("$5: " + fives);
//System.out.println(remainder + " left to go.");
System.out.println("$1: " + remainder);
}
}