-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccount.java
28 lines (28 loc) · 993 Bytes
/
Account.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
//Assignment 18 (sub class)
package Inheritance;
import java.util.*;
class Account extends Bank{
double amt;//instance variable
Account(String n, long l, double x){ //Parameterized constructor
super(n,l,x);//calling the variables from the super class
amt = 0;
}//end of Account()
void deposit(){
System.out.println("Enter the amount to deposit: ");
amt = new Scanner(System.in).nextDouble();
super.p += amt; //amount being deposited
}//end of deposit()
void withdraw(){
System.out.println("Enter the amount to withdraw: ");
amt = new Scanner(System.in).nextDouble();
if(super.p<amt)
System.out.println("Insufficient Balance");
else
super.p -= amt;
if(super.p<500)
super.p = super.p - (500-super.p)/10; //withdraw fine
}//end of withdraw()
void display(){
super.display(); //displaying the details
}//end of display()
}//end of class