-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask11.java
More file actions
59 lines (59 loc) · 1.51 KB
/
Task11.java
File metadata and controls
59 lines (59 loc) · 1.51 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
import java.util.*;
class BankAccount
{
String Dname;
String Atype;
private int Anumber;
long Bamount;
BankAccount(int Actno)
{
Anumber=Actno;
}
public void setDepositor(String depname,String depAtype,int balamount)
{
Dname=depname;
Atype=depAtype;
Bamount=balamount;
}
public float Deposit(float amt)
{
Bamount+=amt;
return Bamount;
}
public float Withdraw(float amt)
{
if(amt==0 || amt>Bamount)
{
System.out.println("Enter Valid Amount ? Thank You!!");
}
else
{
Bamount-=amt;
}
return Bamount;
}
public void Display()
{
System.out.println("Department Name="+Dname);
System.out.println("Account Type="+Atype);
System.out.println("Account Nmuber"+Anumber);
System.out.println("Balance Amount"+Bamount);
}
}
class Task
{
public static void main(String... args)
{
long amt;
Scanner sc = new Scanner(System.in);
BankAccount s=new BankAccount(15454);
s.setDepositor("Sundram Singh","Saving",650000);
s.Display();
System.out.print("Enter the amount for deposit=");
amt=sc.nextInt();
System.out.println("Updated Balance is="+s.Deposit(amt));
System.out.print("Enter the amount for withdraw=");
amt=sc.nextInt();
System.out.println("Updated Balance is="+s.Withdraw(amt));
}
}