forked from akshat-o5/Data-Structures-and-Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode3
More file actions
32 lines (23 loc) · 959 Bytes
/
code3
File metadata and controls
32 lines (23 loc) · 959 Bytes
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
import java.util.Scanner;
class Main {
public static void main(String[] args) {
// create an object of Scanner class
Scanner input = new Scanner(System.in);
// take input from users
System.out.print("Enter the principal: ");
double principal = input.nextDouble();
System.out.print("Enter the rate: ");
double rate = input.nextDouble();
System.out.print("Enter the time: ");
double time = input.nextDouble();
System.out.print("Enter number of times interest is compounded: ");
int number = input.nextInt();
double interest = principal * (Math.pow((1 + rate/100), (time * number))) - principal;
System.out.println("Principal: " + principal);
System.out.println("Interest Rate: " + rate);
System.out.println("Time Duration: " + time);
System.out.println("Number of Time interest Compounded: " + number);
System.out.println("Compound Interest: " + interest);
input.close();
}
}