Skip to content

Commit 21b8947

Browse files
authored
Transact
ATM process of sample Deposit and Withdraw process program coding in Java....
1 parent e63b046 commit 21b8947

File tree

1 file changed

+131
-0
lines changed

1 file changed

+131
-0
lines changed

Transact.java

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
2+
package ThreadExample;
3+
4+
import java.util.Scanner;
5+
6+
public class Transact {
7+
static Transact t=new Transact();
8+
static Scanner sc=new Scanner(System.in);
9+
int current= 5000;
10+
public void welcome() {
11+
System.out.println(" ATM PROCESS");
12+
System.out.println("Your options are:");
13+
System.out.println("1:Deposit");
14+
System.out.println("2:With draw");
15+
System.out.println("3:Balance");
16+
System.out.println("Enter your choice:");
17+
int choice=sc.nextInt();
18+
if(choice==1 ||choice== 2 ||choice== 3 ){
19+
switch(choice){
20+
case 1:
21+
t.Deposit();
22+
break;
23+
case 2:
24+
t.Withdraw();
25+
break;
26+
case 3:
27+
t.Balance();
28+
break;
29+
30+
}
31+
}
32+
else{
33+
System.out.println("You perform Wrong Operation: Only enter the number 1 to 3");
34+
welcome();
35+
}
36+
}
37+
void operation(){
38+
System.out.println("Do you want to continue again? please,Enter Y or y");
39+
char operation=sc.next().charAt(0);
40+
if(operation=='Y' || operation=='y'){
41+
t.welcome();
42+
}
43+
else if(operation=='Z' || operation=='z'){
44+
return;
45+
}
46+
else {
47+
48+
System.out.println("You Should Perform Right Operation only");
49+
t.operation();
50+
}
51+
}
52+
53+
public void method(){
54+
System.out.println("1.current_Account");
55+
System.out.println("2.Savings");
56+
System.out.println("Enter yours choice:");
57+
int cho=sc.nextInt();
58+
if(cho==1 ||cho== 2 ){
59+
switch(cho){
60+
case 1:
61+
t.Current_Account();
62+
break;
63+
case 2:
64+
t.Savings();
65+
break;
66+
}
67+
}
68+
else{
69+
System.out.println("You perform Wrong Operation: Only enter the number 1 to 3");
70+
method();
71+
}
72+
}
73+
void Current_Account(){
74+
System.out.println("Your current balance is:RS."+current);
75+
t.operation();
76+
}
77+
void Savings(){
78+
System.out.println("Enter a money you want:");
79+
t.check();
80+
}
81+
void check(){
82+
int a=sc.nextInt();
83+
if(a<=current){
84+
System.out.println(" !!!! Your Transaction is being processed..... withdraw successful !!!! ");
85+
System.out.println(" Currently your balance is:Rs." +current);
86+
int b=current-a;
87+
System.out.println(" Now your balance is:Rs." +b);
88+
89+
}
90+
91+
else{
92+
System.out.println("please enter a valid number");
93+
Savings();
94+
}
95+
}
96+
97+
void Deposit(){
98+
System.out.println("Welcome to Deposite");
99+
System.out.println("Enter you want to deposit amount:");
100+
t.debit();
101+
}
102+
void debit(){
103+
int a=sc.nextInt();
104+
if(a<=current){
105+
System.out.println("please wait:");
106+
int b=current+a;
107+
System.out.println("!!!!! you deposit a money successfully !!!!!");
108+
System.out.println("Now your available balance is:Rs:" +b);
109+
}
110+
else{
111+
System.out.println("!!!!you should deposit a money Rs:1 to Rs:30000 only!!!!");
112+
}
113+
}
114+
115+
void Withdraw(){
116+
System.out.println("Welcome to Withdraw");
117+
t.method();
118+
}
119+
void Balance(){
120+
System.out.println(" Now your balance is:Rs." +current);
121+
t.operation();
122+
}
123+
124+
125+
public static void main(String[] args){
126+
Transact tr=new Transact();
127+
t.welcome();
128+
129+
}
130+
131+
}

0 commit comments

Comments
 (0)