-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankAccount.java
More file actions
58 lines (45 loc) · 1.5 KB
/
BankAccount.java
File metadata and controls
58 lines (45 loc) · 1.5 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
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();
bank.withdrawal(amount);
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);
}
break;
case 2:{
System.out.print("Enter amount to deposit");
int amount = input.nextInt();
bank.deposit(amount);
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);
}
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;
}
}