-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankAccount.java
More file actions
65 lines (49 loc) · 1.61 KB
/
Copy pathBankAccount.java
File metadata and controls
65 lines (49 loc) · 1.61 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
import java.util.Scanner;
public class BankAccount{
String accountName = "John";
String accountNumber = "4590468934";
double accountBalance = 94746.66;
public static void main(String[] args){
BankAccount bank = new BankAccount();
Scanner input = new Scanner(System.in);
System.out.println("Welcome to UBA Bank");
System.out.println("Enter 1 to withdraw");
System.out.println("Enter 2 to deposit");
System.out.print("Enter your choice- ");
int choice = input.nextInt();
switch(choice) {
case 1:
{
System.out.print("Enter amount to withdraw: ");
int amount = input.nextInt();
System.out.printf("Account name is %s%n", bank.accountName);
System.out.printf("Account number is %s%n", bank.accountNumber);
System.out.printf("Account balance is %.2f%n", bank.accountBalance);
bank.withdrawal(amount);
System.out.printf("Your balanceis %.2f%n",bank.accountBalance);
}
break;
case 2:
{
System.out.print("Enter amount to deposit: ");
int amount = input.nextInt();
System.out.printf("Account name is %s%n", bank.accountName);
System.out.printf("Account number is %s%n", bank.accountNumber);
System.out.printf("Account balance is %.2f%n", bank.accountBalance);
bank.deposit(amount);
System.out.printf("Your balanceis %.2f%n",bank.accountBalance);
}
break;
default:
System.out.println("Invalid Input");
}
}
public double withdrawal(int amount) {
accountBalance -= amount;
return accountBalance;
}
public double deposit(int amount){
accountBalance += amount;
return accountBalance;
}
}