-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleAndCompoundInterest.java
More file actions
36 lines (27 loc) · 1.05 KB
/
Copy pathsimpleAndCompoundInterest.java
File metadata and controls
36 lines (27 loc) · 1.05 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
/*• Write Program to calculate simple interest, and compound interest */
import java.util.*;
import java.lang.Math;
class simpleAndCompoundInterest
{
static
{
double amount,rateOfInterest,simpleInterest,compoundInterest;
int timeInYears,count;
Scanner inPut = new Scanner(System.in);
System.out.print("Enter Initial amount: \n");
amount = inPut.nextDouble();
System.out.print("Enter Rate of Interest: \n");
rateOfInterest = inPut.nextDouble();
System.out.print("Enter Time in Years: \n");
timeInYears = inPut.nextInt();
System.out.print("Enter no. of how many times paid in given period: \n");
count = inPut.nextInt();
simpleInterest = (amount*rateOfInterest*timeInYears)/100;
compoundInterest = amount*Math.pow(1+(rateOfInterest/count),count*timeInYears) - amount;
System.out.print("\n Simple interest for given details: "+simpleInterest);
System.out.print("\n Compound interest for given details: "+ compoundInterest);
System.exit(0);
}
public static void main(String agrs[])
{ }
}