In: Computer Science
Write a program that prints and calls two methods.
1. Compute and return the future value of an account based on the present value of the account, the interest rate, and the number of years.
future value = p * (1 + r / 100) y
Your method should have the following characteristics:
• It should have three double parameters:
• present value
• interest rate
• number of years
• It should return a double, the future value.
• It should use Math.pow in the calculation.
• It should not have any print statements. The main method should do all the printing.
2. Compute and return the future value of an annuity based on the payment per year, the interest rate, and the number of years.
For each method, the main method needs to obtain input from the user, call the method with the input values, save the result of the method in a local variable, and print the inputs and the result.
future value = p *( (1 + r/100)eY - 1) / r/100
Your method should have the following characteristics:
• It should have three double parameters:
• yearly payment
• interest rate
• number of years
• It should return a double, the future value.
• It should use Math.pow in the calculation.
• It should not have any print statements. The main method should do all the printing.
[ USE JAVA TO WORK ON THIS PROBLEM PLEASE]
_____________________________________________________________________________________________________________________________________________________
# This is my work so far:
import java.util.*;
public class Lab3 {
public static void main(String[] args) {
System.out.println("Lab 3 written by Tesfalem Tekie.");
Scanner input = new Scanner(System.in);
System.out.print(" ");// will work on the prompt
double Value = input.nextdouble();
double Rate = input.nextdouble();
double Years = input.nextdouble();
double futureValue = account(Value, Rate, Years);
System.out.println(" ");// keep working
double AnnFutureValue = annuity(Value, Rate, Years);
System.out.println(" ");// keep working
}//end main method
public static double account(double preValue, double intRate,
double numOfYears ) {
double result = Math.sqrt(p*(1 + r/100)eY);// keep working
return result;
}
public static double annuity(double yearly_pay, double int_rate,
double num_of_years) {
double outcome = Math.sqrt(p* ((1 + r/100)eY - 1)/r/100);// keep
working
return outcome;
}
}//end class method
Program:
import java.util.*;
public class Lab3 {
public static void main(String[] args) {
System.out.println("Lab 3 written by Tesfalem Tekie.");
Scanner input = new Scanner(System.in);
System.out.print("Enter amount: ");// will work on the prompt
double Value = input.nextDouble();
System.out.print("Enter interest rate: ");
double Rate = input.nextDouble();
System.out.print("Enter number of years: ");
double Years = input.nextDouble();
double futureValue = account(Value, Rate, Years);
System.out.printf("The future value is %.2f",futureValue);// keep working
double AnnFutureValue = annuity(Value, Rate, Years);
System.out.printf("\nThe annual future value is %.2f",AnnFutureValue);// keep working
}//end main method
public static double account(double p, double r, double Y ) {
double result = p*Math.pow((1 + r/100),Y);// keep working
return result;
}
public static double annuity(double p, double r, double Y) {
double outcome = p * (Math.pow((1 + r/100),Y)-1)/(r/100);// keep working
return outcome;
}
}
Output:.