-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempCodeRunnerFile.java
More file actions
146 lines (105 loc) · 4.6 KB
/
tempCodeRunnerFile.java
File metadata and controls
146 lines (105 loc) · 4.6 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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import java.util.Scanner;
public class ATM_machine {
public static void main(String[] args) {
String cardNo = "200020104110";
String pinNo = "1234";
int cardCount = 0;
int pinCount = 0;
//double balance = 5000.00;
Scanner input = new Scanner(System.in);
while (cardCount<3) {
System.out.println("Welcome to the ATM Machine!");
System.out.println("Please Enter your Card Number:");
String enteredCardNo = input.nextLine();
if (!enteredCardNo.equals(cardNo)) {
System.out.println("Invalid Card Number!");
System.out.println("Please Enter Again!");
cardCount++;
if (cardCount==3) {
System.out.println("You entered your Card Number 3 Times!");
System.out.println("Please Enter your Card Number Again!");
main(args);
}
}
else {
while (pinCount<3) {
System.out.println("Please Enter your Pin Number: ");
String enteredPinNo = input.nextLine();
if (!enteredPinNo.equals(pinNo)) {
System.out.println("Invalid Pin Number!");
System.out.println("Please Enter Again!");
pinCount++;
if (pinCount==3) {
System.out.println("You entered your Pin Number 3 Times!");
System.out.println("Please Enter your pin Number Again!");
main(args);
}
}
else {
System.out.println("Do You want to continue Transaction?");
System.out.println("\n\t\t\t\t (1)Yes");
System.out.println("\n\t\t\t\t (2)No");
int continueTransaction = input.nextInt();
if (continueTransaction==1) {
System.out.println("Please Choose your option!");
System.out.println("\n\t\t\t\t (1) Check your Balance");
System.out.println("\n\t\t\t\t (2) Withdraw your Money");
System.out.println("\n\t\t\t\t (3) Deposit your Money");
System.out.println("\n\t\t\t\t (4) Cancel");
int choice = input.nextInt();
switch (choice) {
case 1:
Balance();
break;
case 2:
Withdraw();
break;
case 3:
Deposit();
break;
case 4:
main(args);
}
}
if (continueTransaction==2) {
System.exit(continueTransaction);
}
}
}
}
}
}
static void Balance() {
System.out.println("Your Balance is Rs.5000.00");
}
static void Withdraw() {
double balance = 5000.00;
Scanner amount = new Scanner(System.in);
System.out.println("Please Enter your amount of Withdrawing");
double withdrawl = amount.nextDouble();
if (withdrawl >= balance) {
System.out.println("Insufficient Balance!");
System.out.println("Try Again!");
}
else {
System.out.println("Your Withdrawn Money is " + withdrawl);
double newBalance = balance - withdrawl;
System.out.println("Your New Balance is " + newBalance);
}
}
static void Deposit() {
double balance = 5000.00;
Scanner amount = new Scanner(System.in);
System.out.println("Please Enter your amount of Depositing");
double diposit = amount.nextDouble();
if (diposit >= balance) {
System.out.println("Insufficient Balance!");
System.out.println("Try Again!");
}
else {
System.out.println("Your Depositted Money is " + diposit);
double newBalance = balance + diposit;
System.out.println("Your New Balance is " + newBalance);
}
}
}