-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBankC.java
44 lines (43 loc) · 914 Bytes
/
BankC.java
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
//Bank-constructor
import java.util.*;
class BankC
{
Scanner sc = new Scanner(System.in);
String name,acc_type;
int acc_no;
double balance,deposit,withdraw;
BankC (String n,String type, int no,double b) //constructor
{
name=n;
acc_type=type;
acc_no=no;
balance=b;
}
void DepAmt()
{
System.out.println("Enter amount to deposit: ");
deposit=sc.nextDouble();
balance=balance+deposit;
}
void wdraw()
{
System.out.println("Enter withdrawal amount: ");
withdraw=sc.nextDouble();
if (balance<withdraw)
System.out.println("Insuffient balance");
else
balance=balance-withdraw;
}
void display()
{
System.out.println("Account name: " +name);
System.out.println("Balance: "+balance);
}
public static void main(String args[])
{
BankC ob = new BankC("Khushi","Savings",42,1000);
ob.DepAmt();
ob.wdraw();
ob.display();
}
}