-
Notifications
You must be signed in to change notification settings - Fork 0
/
JAVA.jav
69 lines (61 loc) · 2.56 KB
/
JAVA.jav
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
import java.util.*;
public class ATM {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter username:");
String name = sc.next();
System.out.println("Enter your pin:");
sc.next();
System.out.println("Login Successful!!\n\nWelcome " + name);
int bal = 0, n;
String hist = "";
do {
System.out.println(
"\n\nChoose your options \n1.Withdraw \n2.Deposit \n3.Transfer \n4.Transaction History \n5.Exit");
int ans = sc.nextInt();
switch (ans) {
case 1:
System.out.println("Enter withdrawl amount:");
int x = sc.nextInt();
if (bal >= x) {
bal -= x;
System.out.println("Operation Successfull");
hist += String.valueOf(x) + " Amount withdrawn\n";
} else
System.out.println("Operation Failed");
break;
case 2:
System.out.println("Enter deposit amount:");
int y = sc.nextInt();
if (y <= 50000) {
bal += y;
System.out.println("Operation Successfull");
hist += String.valueOf(y) + " Amount deposited\n";
} else
System.out.println("Amount is too large\n Sorry can't deposit");
break;
case 3:
System.out.println("Enter amount to transfer");
int z = sc.nextInt();
System.out.println("Enter account holders username to transfer money to");
String trans = sc.next();
bal -= z;
System.out.println("Operation Successfull");
hist += String.valueOf(z) + " amount transferred to " + trans + "\n";
break;
case 4:
System.out.println("Your transaction history is:\n" + hist);
case 5:
break;
}
System.out.println("Do you want to continue?\n1.Yes\n2.No");
n = sc.nextInt();
} while (n == 1);
sc.close();
}
@Override
protected Object clone() throws CloneNotSupportedException {
// TODO Auto-generated method stub
return super.clone();
}
}