-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM_Interface_task3.java
More file actions
71 lines (70 loc) · 1.87 KB
/
ATM_Interface_task3.java
File metadata and controls
71 lines (70 loc) · 1.87 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
import java.util.Scanner;
class ATM_Interface_task3
{
static Scanner scan=new Scanner(System.in);
static class ATM
{
ACCOUNT o=new ACCOUNT();
int withdraw()
{
System.out.print("\nWITHDRAW AMOUNT\nenter amount: ");
float n=scan.nextFloat();
if(n>o.balance)
{
System.out.println("INSUFFICIENT FUNDS");
return 1;
}
else
{
o.balance-=n;
System.out.println("WITHDRAW SUCCESFUL");
return 0;
}
}
void deposit()
{
System.out.println("\nDEPOSIT AMOUNT\nenter amount: ");
float n=scan.nextFloat();
o.balance+=n;
System.out.println("DEPOSIT SUCCESFUL");
}
void enquiry()
{
System.out.println("\nCURRENT BALANCE\n"+o.balance);
}
}
static class ACCOUNT
{
float balance=0;
}
public static void main(String[] args)
{
System.out.println("ATM INTERFACE");
ATM o=new ATM();
while(true)
{
System.out.println("\n1. Withdraw Amount\n2. Deposit Amount\n3. Check Balance\n4. Exit");
int n=scan.nextInt();
switch(n)
{
case 1:
if(o.withdraw()==1)
{
o.enquiry();
}
break;
case 2:
o.deposit();
break;
case 3:
o.enquiry();
break;
case 4:
System.out.println("THANK YOU!!!!!");
System.exit(0);
default:
System.out.println("INVALID REQUEST");
}
}
}
}