-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank_Cashier.java
More file actions
75 lines (75 loc) · 1.54 KB
/
Copy pathBank_Cashier.java
File metadata and controls
75 lines (75 loc) · 1.54 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
import java.util.Scanner;
class Bank_Cashier
{
public static void main(String args[])
{
String p,q;
int r,s;
Scanner sc=new Scanner(System.in);
System.out.println("enter the name, account number, principal amount, amount to deposit or withdrawn");
p=sc.nextLine();
q=sc.nextLine();
r=sc.nextInt();
s=sc.nextInt();
Account obj=new Account(p,q,r,s);
System.out.println("1.deposit"+"\n"+"2.withdraw");
int c;
c=sc.nextInt();
switch(c)
{
case 1:
obj.deposit();
obj.display();
break;
case 2:
obj.withdraw();
obj.display();
break;
default:
System.out.println("Invalid choice!");
}
}
}
class Account extends Bank
{
int amt;
Account(String w,String x,int y,int z)
{
super(w,x,y);
amt=z;
}
void deposit()
{
p=p+amt;
}
void withdraw()
{
if(amt>p)
System.out.println("INSUFFICIENT BALANCE");
else
p=p-amt;
if(p<500)
p=p-(500-p)/10;
}
void display()
{
super.display();
}
}
class Bank
{
String name,accno;
int p;
Bank(String a,String b,int c)
{
name=a;
accno=b;
p=c;
}
void display()
{
System.out.println("the name "+name);
System.out.println("the account number "+accno);
System.out.println("the principal amount "+p);
}
}