forked from 0xali3n/Hactoberfest-Beginner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 0xali3n#128 from Manali71/main
Added Compound Interest.java
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import static java.lang.Math.pow; | ||
|
||
class CompundInterest | ||
{ | ||
public static void main(String args[]) | ||
{ | ||
|
||
double amount=0,principle,rate,time,ci,t=1; | ||
|
||
|
||
|
||
Scanner sc=new Scanner(System.in); | ||
|
||
System.out.println("enter principle "); | ||
|
||
principle=sc.nextDouble(); | ||
|
||
System.out.println("enter rate"); | ||
|
||
rate=sc.nextDouble(); | ||
|
||
System.out.println("enter time"); | ||
|
||
time=sc.nextDouble(); | ||
|
||
rate=(1+rate/100); | ||
|
||
for(int i=0;i<time;i++) | ||
t*=rate; | ||
|
||
|
||
amount=principle*t; | ||
|
||
System.out.println("amount="+amount); | ||
|
||
ci=amount-principle; | ||
|
||
System.out.println("compound intrest="+ci); | ||
|
||
} | ||
} |