-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDollars.java
More file actions
55 lines (47 loc) · 1.63 KB
/
Copy pathDollars.java
File metadata and controls
55 lines (47 loc) · 1.63 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Writen by Edgar Colin
// Aug 7th 2016
// Class: CIS163 Java I
// Prof: Michael Parmeley
// Section 14887
// HW 2 Problem 10 Modified
// Filename: DogBoarding.java
import javax.swing.JOptionPane;
import java.util.Scanner;
public class Dollars
{
public static void main(String[] args) // Main Function
{
int Dollars; // Defining Dollar Amount
String DollarString; // String to be use as
// input dialo®g storage
/* Defining denominations
to split the dollar amount
into bills of 20,10,5,
and 1 dollar
*/
final int Twenty = 20;
final int Ten = 10;
final int Five = 5;
final int Ones = 1;
/* Message pane with message and input box,
Input is stored as a string into
the DollarString variable*/
DollarString = JOptionPane.showInputDialog(null,
"Please enter the dollar amount to be split"
+ " into currency \ndenominations of "
+ "$20s, $10s , $5s, $1s bills ",
"Salary dialog 1",
JOptionPane.INFORMATION_MESSAGE);
/* Changed variable type DollarString input to an
integer type variable Dollar for computation use*/
Dollars = Integer.parseInt(DollarString);
JOptionPane.showMessageDialog(null,
"\nThe dollar amount of $"+ Dollars + " split"
+ " into currency with \ndenominations of "
+ "$20, $10, $5, and $1 bills,"
+ "\n in the least amount of bills is : \n"
+ "$"+Dollars + " = " + Dollars/20 + " $20s, "
+ (Dollars%20)/10 + " 10s, "+ ((Dollars%20)%10)/5 +
" 5s, " + (((Dollars%20)%10)%5)/1 + " 1s ."); // message pane w/ output
}
}