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
25 lines (23 loc) · 845 Bytes
/
Withdrawal.java
File metadata and controls
25 lines (23 loc) · 845 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
import java.text.DecimalFormat;
public class Withdrawal
{
public static void main(String[] args)
{
int withdrawal = 137;
double fee;
int twenties = withdrawal / 20;
int remainder = withdrawal % 20;
int tens = remainder / 10;
remainder = remainder % 10;
int fives = remainder / 5;
remainder = remainder % 5;
int ones = remainder / 1;
fee = 0.10 * (twenties + tens + fives + ones);
System.out.print("$20" + "( " + twenties + " )" + ", ");
System.out.print("$10" + "( " + tens + " )" + ", ");
System.out.print("$5" + "( " + fives + " )" + ", ");
System.out.println("$1" + "( " + ones + " )");
DecimalFormat df = new DecimalFormat("#.00");
System.out.print("Transaction Fee: " + df.format(fee + 1.00));
}
}