-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathBank account.java
More file actions
73 lines (72 loc) · 1.99 KB
/
Bank account.java
File metadata and controls
73 lines (72 loc) · 1.99 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
/* Bank Account Program */
import java.util.Scanner;
class Account
{
String name;
int acno;
char type;
float balance;
void initialize()
{
name="Amit";
acno=1001;
type='S';
balance=1200;
}
void deposit(float amt)
{
balance=balance+amt;
System.out.println("Rs. "+amt+" is deposited successfully.");
}
void withdraw(float amt)
{
if((balance-amt)<1000)
{
System.out.println("Insufficient Balance");
}
else
{
balance=balance-amt;
System.out.println("Rs. "+amt+" is withdrawn successfully.");
}
}
void show()
{
System.out.println("Name :"+name);
System.out.println("Balance :"+balance);
}
}
class BankAccount
{
public static void main(String args[])
{
Account ac=new Account();
int opt;
float amt;
Scanner sc=new Scanner(System.in);
ac.initialize();
do
{
System.out.println("*******MENU*****");
System.out.println("1. Deposit\n2. Withdraw\n3. Show\n4. Exit\n");
System.out.println("Enter your option:");
opt=sc.nextInt();
switch(opt)
{
case 1: System.out.println("Enter the amount:");
amt=sc.nextFloat();
ac.deposit(amt);
break;
case 2: System.out.println("Enter the amount:");
amt=sc.nextFloat();
ac.withdraw(amt);
break;
case 3:
ac.show();
break;
default:
System.exit(1);
}
}while(opt!=4);
}
}