-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCashCounter.java
More file actions
84 lines (66 loc) · 1.34 KB
/
Copy pathCashCounter.java
File metadata and controls
84 lines (66 loc) · 1.34 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package datastructures;
import bridgelabz.utility.utility;
public class CashCounter
{
public static void main(String[] args)
{
System.out.println("enter 1.deposit 2.withdrawal 3.display amount 4.quit");
int choice=utility.getint();
CashCounter.choice(choice);
}
public static void choice(int ch)
{
switch(ch)
{
case 1:
deposit();
break;
case 2:
withdrawl();
break;
case 3:
displayBal();
break;
case 4:
Queue.printlist();
break;
default:
System.out.println("invalid ");
break;
}
}
public static void deposit()
{
System.out.println("enter the amount to deposit");
int amount=0;
int deposit=utility.getint();
amount=amount+deposit;
Queue.enqueue(deposit);
System.out.println("balance " + Queue.totalAmount());
System.out.println("1.depost 2.withdrawl 3.dispaly balance 4.quit");
int choice1 =utility.getint();
choice(choice1);
}
public static void withdrawl()
{
System.out.println("enter the amount to withdrawl");
int amount=utility.getint();
int bal=Queue.totalAmount();
if(bal>amount)
{
Queue.dequeue();
int bal1=Queue.totalAmount();
System.out.println("remaining bal " + bal1);
System.out.println("enter 1.deposit 2.withdrwal 3.display 4.quit");
}
else
{
System.out.println("insuff balance");
}
}
public static void displayBal()
{
int bal=Queue.totalAmount();
System.out.println("remaing balance " +bal);
}
}