-
Notifications
You must be signed in to change notification settings - Fork 1
/
Transact.java
131 lines (117 loc) · 3.04 KB
/
Transact.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package ThreadExample;
import java.util.Scanner;
public class Transact {
static Transact t=new Transact();
static Scanner sc=new Scanner(System.in);
int current= 5000;
public void welcome() {
System.out.println(" ATM PROCESS");
System.out.println("Your options are:");
System.out.println("1:Deposit");
System.out.println("2:With draw");
System.out.println("3:Balance");
System.out.println("Enter your choice:");
int choice=sc.nextInt();
if(choice==1 ||choice== 2 ||choice== 3 ){
switch(choice){
case 1:
t.Deposit();
break;
case 2:
t.Withdraw();
break;
case 3:
t.Balance();
break;
}
}
else{
System.out.println("You perform Wrong Operation: Only enter the number 1 to 3");
welcome();
}
}
void operation(){
System.out.println("Do you want to continue again? please,Enter Y or y");
char operation=sc.next().charAt(0);
if(operation=='Y' || operation=='y'){
t.welcome();
}
else if(operation=='Z' || operation=='z'){
return;
}
else {
System.out.println("You Should Perform Right Operation only");
t.operation();
}
}
public void method(){
System.out.println("1.current_Account");
System.out.println("2.Savings");
System.out.println("Enter yours choice:");
int cho=sc.nextInt();
if(cho==1 ||cho== 2 ){
switch(cho){
case 1:
t.Current_Account();
break;
case 2:
t.Savings();
break;
}
}
else{
System.out.println("You perform Wrong Operation: Only enter the number 1 to 3");
method();
}
}
void Current_Account(){
System.out.println("Your current balance is:RS."+current);
t.operation();
}
void Savings(){
System.out.println("Enter a money you want:");
t.check();
}
void check(){
int a=sc.nextInt();
if(a<=current){
System.out.println(" !!!! Your Transaction is being processed..... withdraw successful !!!! ");
System.out.println(" Currently your balance is:Rs." +current);
int b=current-a;
System.out.println(" Now your balance is:Rs." +b);
}
else{
System.out.println("please enter a valid number");
Savings();
}
}
void Deposit(){
System.out.println("Welcome to Deposite");
System.out.println("Enter you want to deposit amount:");
t.debit();
}
void debit(){
int a=sc.nextInt();
if(a<=current){
System.out.println("please wait:");
int b=current+a;
System.out.println("!!!!! you deposit a money successfully !!!!!");
System.out.println("Now your available balance is:Rs:" +b);
}
else{
System.out.println("!!!!you should deposit a money Rs:1 to Rs:30000 only!!!!");
}
}
void Withdraw(){
System.out.println("Welcome to Withdraw");
t.method();
}
void Balance(){
System.out.println(" Now your balance is:Rs." +current);
t.operation();
}
public static void main(String[] args){
Transact tr=new Transact();
t.welcome();
}
}