Write a Java test program, all your code should be in the main method, that asks
ID: 3551257 • Letter: W
Question
Write a Java test program, all your code should be in the main method, that asks the user for two numbers representing an investment value and interest rate. Expect the user to enter the interest rate as a real number, so a rate of %6.5 would be entered as 0.065. Your program should calculate the future value of the investment for 5, 10, 15, and 20 years. The formula for future value, using compounding interest, is as follows:
fv = investment * (1 + interestRate)years
Please use JGrasp.(.java file)
Explanation / Answer
/* https://gist.github.com/bitwiser/9247324 */
import java.util.*;
import java.lang.*;
class test{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
int investment;
double interest,fv5,fv10,fv15,fv20;
System.out.print("Enter investment: ");
investment = s.nextInt();
System.out.print("Enter interest: ");
interest = s.nextDouble();
fv5 = investment*Math.pow((1+interest),5);
fv10 = investment*Math.pow((1+interest),10);
fv15 = investment*Math.pow((1+interest),15);
fv20 = investment*Math.pow((1+interest),20);
System.out.println("Future value for 5 yr: "+fv5);
System.out.println("Future value for 10 yr: "+fv10);
System.out.println("Future value for 15 yr: "+fv15);
System.out.println("Future value for 20 yr: "+fv20);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.