Write a Java method to compute the future investment value at a given interest rate for a specified number of years.
Sample data (Monthly compounded) and Output:
Input the investment amount: 1000
Input the rate of interest: 10
Input number of years: 5
import java.util.Scanner;
class App {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Input the investment amount: ");
double principal = scan.nextDouble();
System.out.print("Enter Rate of Interest : ");
double rate = scan.nextDouble();
System.out.print("Input number of years: ");
int time = scan.nextInt();
double p = (principal * rate * time) / 100;
System.out.println("Payment: " + p);
}
}
Comments
Leave a comment