Answer to Question #258550 in Java | JSP | JSF for liza

Question #258550

Write a Java method to compute the future investment value at a given interest rate for a  


specified number of years. 


Input the investment amount: 1000  

Input the rate of interest: 10  

Input number of years: 5  

Years FutureValue  

1 1104.71  

2 1220.39  

3 1348.18  

4 1489.35  

5 1645.31 


1
Expert's answer
2021-10-30T13:32:36-0400


package interest;


import java.util.Scanner;
public class Interest {


    
    public static void main(String[] args) {
        System.out.printf("Input the investment amount:  ");
        Scanner scan = new Scanner(System.in);
        double amount = scan.nextDouble();
        System.out.printf("\nInput the rate of interest:  ");
        double rate = scan.nextDouble() * 0.01;
        System.out.printf("\nInput number of years:  ");
        
        int years = scan.nextInt();
        System.out.printf("\nYears FutureValue ");
        for(int i=1; i<=years; i++){
            double interest = (amount * rate * i);
            
            double total  = amount + interest;
            System.out.printf("\n"+total);
            amount  = total;
            System.out.printf("\n%d\t %f ", (i), total);
        }
        
        
    }
    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS