Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

problem 6.7 page 235, Introduction of java Programming 10th edition, 1)Write a m

ID: 3861776 • Letter: P

Question

problem 6.7 page 235, Introduction of java Programming 10th edition,
1)Write a method that computes future investment value at a given interest rate for a special number of years. The future investment is determined using the formula in Programming Exercise 2.21 Use the following method header:

public static double futureInvestmentValue(

double investmentAmount, double monthlyInterestRate, int years)

for example, futureInvestmentValue(10000, 0.05/12, 5) reutrns 12833.59

write a test program that prompts the user to enter the investment amount (e.g., 1000) and interest rate (e.g., 9%) and prints a table that displays future value for the years from 1 to 30 as shown below:

the amount invested: 1000 (enter0

Annual interest rate: 9 (enter)

1 1093.83

2 1196.41

...

29 13467.25

30 14730.57

problem 2) (convert milliseconds to hours, minutes, and seconds) Write a method that converts mill, to hours, minutes, and seconds using the following header:

public static String convertMillis(long millis)

the method returns a string as hours:minutes:seconds. for example, convertMillis(5500) returns a string 0:05, convert Millis(100000) returns a string 0:1:40, and convertMillis(555550000) returns a string 154:19:10.

problem 3)The area of a pentagon can be computed using the following formula: AREA = 5xs^2 / 4xtan(pie/5)

write a mthod that returns athe area of a pentagon using the following header:

public static double area(double side)

write a main method that prompts the user to enter the side of a pentagon and display its area. Here is a sample run:

Enter the side:5.5 (enter)

The area of the pentagon is 52.04444136781625

Explanation / Answer

Solution to problem 1)
import java.lang.*;
import java.util.Scanner;
public class futureInvest{
     public static double futureInvestmentValue(double investmentAmount,
        double monthlyInterestRate, int years) {
            return investmentAmount * Math.pow(1.0 + monthlyInterestRate, 12 * years);
        }
     public static void main(String []args){
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter the amount Invested");
        double investmentAmount = scanner.nextDouble();
        System.out.println("Enter Annual interest Rate");
        double annualInterestRate = scanner.nextDouble();
        for (int i = 1; i <= 30; i++) {
           System.out.println(i + "     "+ futureInvestmentValue(investmentAmount, annualInterestRate / 1200.0, i));
        }
     }
}