File tree Expand file tree Collapse file tree 2 files changed +76
-0
lines changed
Expand file tree Collapse file tree 2 files changed +76
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .util .*;
2+ public class Calculate_Interest
3+ {
4+ public static void main (String [] args )
5+ {
6+ Scanner sc = new Scanner (System .in );
7+
8+ int a = sc .nextInt ();sc .nextLine ();
9+ double b = sc .nextDouble ();sc .nextLine ();
10+ double c = sc .nextDouble ();sc .nextLine ();
11+ Account ac = new Account (a ,b ,c );
12+
13+ int n = sc .nextInt ();
14+
15+ double interest = calculateInterest (ac , n );
16+
17+ System .out .format ("%.3f" ,interest );
18+
19+ }
20+ public static double calculateInterest (Account ac , int n )
21+ {
22+ double per = (ac .getInterestRate ()/100 )*n ;
23+ per = ac .getInterestRate ()+per ;
24+ return per ;
25+ }
26+ }
27+ class Account
28+ {
29+ int id ;
30+ double balance ;
31+ double interestRate ;
32+
33+ public Account (int id , double balance , double interestRate )
34+ {
35+ this .id = id ;
36+ this .balance = balance ;
37+ this .interestRate = interestRate ;
38+ }
39+
40+ public int getId ()
41+ {
42+ return id ;
43+ }
44+ public void setId (int id )
45+ {
46+ this .id = id ;
47+ }
48+ public double getBalance ()
49+ {
50+ return balance ;
51+ }
52+ public void setBalance (double balance )
53+ {
54+ this .balance = balance ;
55+ }
56+ public double getInterestRate ()
57+ {
58+ return interestRate ;
59+ }
60+ public void setInterestRate (double interestRate )
61+ {
62+ this .interestRate = interestRate ;
63+ }
64+ }
Original file line number Diff line number Diff line change 1+ Find total interest of an amount.
2+
3+ Create a class Account with following attributes :
4+ id - int
5+ balance - double
6+ interestRate - double
7+
8+ Take another integer as number of year.
9+ After that calculate total interest using formula:
10+
11+ Percentage = interestRate * 100 / time
12+ Total Interest = Percentage + interestRate
You can’t perform that action at this time.
0 commit comments