-
Notifications
You must be signed in to change notification settings - Fork 360
/
Atm machine program
58 lines (43 loc) · 2.03 KB
/
Atm machine program
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
package atmmachine;
import java.util.Scanner;
/**
*
* @author arifur.rahman
*/
public class ATMMachine {
public static void main(String[] args) {
String userName = "Ami Alif";
String password = "1234Abcd";
String bankName = "AA Bank Limited";
double userBalance = 5000;
Scanner bankScanner = new Scanner(System.in);
System.out.println("Welcome to " + bankName);
System.out.println("Please Enter Your PIN Number ");
String enteredPassword = bankScanner.nextLine();
if (enteredPassword.equalsIgnoreCase(password)) {
System.out.println("Account Name Holder : " + userName);
System.out.println("Please choose the following options ");
System.out.println("1 - Show Balance , 2 - Deposit Amount , 3 - Withdraw Amount");
int userChoice = bankScanner.nextInt();
if (userChoice == 1) {
System.out.println("Your Current Balance is " + userBalance);
} else if (userChoice == 2) {
System.out.println("Please Enter The Amount To Deposit ");
double depositAmount = bankScanner.nextDouble();
userBalance += depositAmount;
System.out.println("You have successfully deposited " + depositAmount
+ " \nNow your balnce is " + userBalance);
} else if (userChoice == 3) {
System.out.println("Please Enter the Amount to Witdraw");
double withdrawAmount = bankScanner.nextDouble();
if (withdrawAmount > userBalance) {
System.out.println("Insufficient Balance. Please Try Again");
} else {
userBalance -= withdrawAmount;
System.out.println("You have successfully withdraw " + withdrawAmount
+ " \nNow your balnce is " + userBalance);
}
}
}
}
}