-
Notifications
You must be signed in to change notification settings - Fork 0
/
Atm.java
63 lines (50 loc) · 1.8 KB
/
Atm.java
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
import java.util.Scanner;
public class Atm {
static double Cash() {
try (Scanner sc = new Scanner(System.in)) {
System.out.print("Enter Withdraw amount:");
double wamt = sc.nextDouble();
return wamt;
}
}
public static double bal(double wamt) {
return wamt;
}
public static double balance(double wamt) {
double balance = 1000 + wamt;
System.out.print(balance);
return balance;
}
public static void checkwithraw(double wamt, double balance) {
if (balance > wamt) {
System.out.println("Please wait for cash\n Please collect cash\n Thank you");
} else
System.out.println("Not Enough Money");
}
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
System.out.print("Enter your ID:");
int id = sc.nextInt();
System.out.print("Enter password:");
int pass = sc.nextInt();
if (id == 102 && pass == 12345) {
System.out.println("1.Cash withraw\n2.Check balance\n3.Cash Deposit\n4.Exit");
int fun1 = sc.nextInt();
if (fun1 == 1) {
Cash();
bal(fun1);
checkwithraw(Cash(), balance(fun1));
System.out.println("1.Exit\n2.Show Balance");
int bal = sc.nextInt();
if (bal == 1) {
System.out.println("Thank you for using atm");
} else if (bal == 2) {
double c = balance(bal);
System.out.println(c);
}
}
} else
System.out.println("Enter valid input");
}
}
}