-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path3.java
More file actions
48 lines (46 loc) · 1.02 KB
/
3.java
File metadata and controls
48 lines (46 loc) · 1.02 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
import java.util.*;
class Account{
float balance;
}
class SavingsAccount extends Account
{
float interest;
SavingsAccount(float f)
{
interest =f;
}
public float addinterst(float b)
{
balance= b + (b*(interest/100));
return balance;
}
}
class CurrentAccount extends Account
{
float interest;
CurrentAccount(float f)
{
interest =f;
}
public float addinterst(float b)
{
balance= b + (b*(interest/100));
return balance;
}
}
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner (System.in);
System.out.println("Enter the balance in your account");
float f = sc.nextFloat();
System.out.println("Enter the interest you recieve in %");
float i =sc.nextFloat();
SavingsAccount ob = new SavingsAccount(i);
CurrentAccount ob1 = new CurrentAccount(i);
float b = ob.addinterst(f);
System.out.println("New balance in Savings Account is "+b);
b= ob1.addinterst(f);
System.out.println("New balance in Current Account is "+b);
}
}