-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.java
More file actions
79 lines (71 loc) · 1.86 KB
/
Copy pathProject.java
File metadata and controls
79 lines (71 loc) · 1.86 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
import java.util.Scanner;
class ATM {
float Balance;
int PIN=4567;
public void Checkpin(){
System.out.println("Enter Your Pin:");
Scanner sc= new Scanner(System.in);
int Enteredpin=sc.nextInt();
if(Enteredpin == PIN){
menu();
}else {
System.out.println("Invaild Pin Try Again");
}
Checkpin();
}
public void menu(){
System.out.println("Enter Your Choice :");
System.out.println("1. Check A/C Balance");
System.out.println("2. Withdraw Money ");
System.out.println("3. Deposit Money ");
System.out.println("4. Exit");
System.out.println("choose your Option :");
Scanner sc= new Scanner (System.in);
int opt=sc.nextInt();
if(opt==1){
CheckBalance();
}else if(opt == 2){
WithdrawMoney();
}else if(opt == 3){
DepositMoney();
}else if(opt == 4){
return;
}else{
System.out.println("Invaild");
}
}
public void CheckBalance(){
System.out.println("your Balance:"+Balance );
menu();
}
public void WithdrawMoney(){
System.out.println("Enter Your Amount:");
Scanner sc= new Scanner(System.in);
float Amount=sc.nextFloat();
if(Amount > Balance){
System.out.println("Insficient Balance");
}else {
Balance= Amount - Balance;
System.out.println("Withdrawn Successfuly");
menu();
}
menu();
}
public void DepositMoney(){
System.out.println("Enter the Amount");
Scanner sc= new Scanner(System.in);
float Amount=sc.nextFloat();
Balance= Balance + Amount;
System.out.println("Money Deposit Is Sucessfully");
}
}
public class Project{
public static void main(String[] args) {
ATM obj= new ATM ();
obj.Checkpin();
obj.CheckBalance();
obj.DepositMoney();
obj.WithdrawMoney();
//obj.Checkpin();
}
}