cash register program java

Solutions on MaxInterview for cash register program java by the best coders in the world

showing results for - "cash register program java"
Roberto
22 Jan 2019
1for (Denomination d : Denomination.values()) {
2    while (cashBack >= d.getValue()) {
3        cashBack -= d.getValue();
4        change.append(d).append(',');
5    }
6}
7public enum Denomination {
8    ONE_HUNDRED(100.00f),
9          FIFTY( 50.00f),
10         TWENTY( 20.00f),
11            TEN( 10.00f),
12           FIVE(  5.00f),
13            TWO(  2.00f),
14            ONE(  1.00f),
15    HALF_DOLLAR(  0.50f),
16        QUARTER(  0.25f),
17           DIME(  0.10f),
18         NICKEL(  0.05f),
19          PENNY(  0.01f);
20
21    private final float value;
22    private final String description;
23
24    Denomination(float value) {
25        this.value = value;
26        this.description = this.name().replace("_", " ");
27    }
28
29    public float getValue() {
30        return this.value;
31    }
32
33    @Override
34    public String toString() {
35        return this.description;
36    }
37}