Question

Please use public class for java. Thank you.

1. (10 points) Write a method that computes future investment value at a given interest rate for a specified number of years.

2. (10 points) Write a method that determines if a given non-negative integer is a prime number, use the following method hea

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;
public class Invest{
public static double futureInvestmentValue(double inestmentAmount,double monthlyInterestRate,int years)
{
return inestmentAmount*Math.pow(1.0+monthlyInterestRate,years*12.0);
}
public static void main(String []args){
Scanner sc = new Scanner(System.in);
System.out.println("The amount invested: ");
double amt=sc.nextDouble();
System.out.println("Annual interest rate: ");
double r=sc.nextDouble();
System.out.println("Years\tFuture Value");
r=r/100.0;
for(int i=1;i<=30;i++)
System.out.printf("%d\t%.2f\n",i,futureInvestmentValue(amt,r/12.0,i));
}
}

Add a comment
Know the answer?
Add Answer to:
Please use public class for java. Thank you. 1. (10 points) Write a method that computes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Computing Future Investment Value Problem Description: Write a method that computes future investment value at a...

    Computing Future Investment Value Problem Description: Write a method that computes future investment value at a given interest rate for a specified number of years. The future investment is determined using the following formula: 12 futurelnvestmentValue investmentAmountx(1+ monthlylnterestRate) Use the following method header: publie static double futureInvestnentValue double investnentAmount, double monthlyInterestRate, int years) For example, futur Investmentvalue( 1eeee, อ.es/12, 5) returns 12833.59 Write a test program that prompts the user to enter the investment amount (e.g. 1000) and the interest...

  • Please show screenshot outputs and fully functional code for the Java programs. Question 1: Write a...

    Please show screenshot outputs and fully functional code for the Java programs. Question 1: Write a method that computes and returns the area of a square using the following header: public static double area ( double side) Write a main method that prompts the user to enter the side of a square, calls the area method then displays the area. Question 1a: Write a method that converts miles to kilometers using the following header: public static double convertToKilometers (double miles)...

  • Write a method to multiply two matrices. The header of the method is: public static double[][]...

    Write a method to multiply two matrices. The header of the method is: public static double[][] multiplyMatrix(double[][] a, double[][] b) To multiply matrix a by matrix b, the number of columns in a must be the same as the number of rows in b, and the two matrices must have elements of the same or compatible types. Let c be the result of the multiplication. Assume the column size of matrix a is n. Each element is For example, for...

  • I need to Write a test program that prompts the user to enter 10 double values...

    I need to Write a test program that prompts the user to enter 10 double values into an array, calls a method to calculate the average of the numbers, and displays the average. Next, write a method that returns the lowest value in the array and display the lowest number. The program should then prompt the user to enter 10 integer values into an array, calculates the average, and displays the average. The program should have two overloaded methods to...

  • I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that a...

    I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...

  • Create a method based program to find if a number is prime and then print all...

    Create a method based program to find if a number is prime and then print all the prime numbers from 1 through 500 Method Name: isPrime(int num) and returns a boolean Use for loop to capture all the prime numbers (1 through 500) Create a file to add the list of prime numbers Working Files: public class IsPrimeMethod {    public static void main(String[] args)    {       String input;        // To hold keyboard input       String message;      // Message...

  • this is for java class Define a utility class for displaying values of type double. Call...

    this is for java class Define a utility class for displaying values of type double. Call the class DoubleOut. Include all the methods from the class DollarFormat in Listing 6.14, all the methods from the class OutputFormat of Self-Test Question 30, and a method called scienceWrite that displays a value of type double using e notation, such as 2.13e–12. (This e notation is also called scientific notation, which explains the method name.) When displayed in e notation, the number should...

  • Write a test program that prompt the user to enter seven numbers, stores them in an...

    Write a test program that prompt the user to enter seven numbers, stores them in an array list and do the following: 1. Displays its elements (numbers) in increasing order by invoking a method with the following header that sorts the array: public static void sort(ArrayList<Integer>list) 2. Write a method that returns and displays the sum of all numbers (elements) of the ArrayList. Using the following header: public static double sum(ArrayList<Integer>list) 3. Write a method that removes the duplicate numbers...

  • public static void main(String[] args) {         System.out.println("Welcome to the Future Value Calculator\n");         Scanner sc...

    public static void main(String[] args) {         System.out.println("Welcome to the Future Value Calculator\n");         Scanner sc = new Scanner(System.in);         String choice = "y";         while (choice.equalsIgnoreCase("y")) {             // get the input from the user             System.out.println("DATA ENTRY");             double monthlyInvestment = getDoubleWithinRange(sc,                     "Enter monthly investment: ", 0, 1000);             double interestRate = getDoubleWithinRange(sc,                     "Enter yearly interest rate: ", 0, 30);             int years = getIntWithinRange(sc,                     "Enter number of years: ", 0, 100);             System.out.println();            ...

  • need source code for NetBeans here is the file Write a class PrimeSequence that implements the Sequence inte...

    need source code for NetBeans here is the file Write a class PrimeSequence that implements the Sequence interface of Worked Example 10.1* and produces a sequence of prime numbers. * See Files section bj6_ch10_we.pdf Hint: Pseudocode to produce next prime: class Prime Sequence implements Sequence instance variable int p function next ()I isPrime-true While (isPrime) increment p; for (d-2; until d*d > p divides p) isPrime-false; d+) if (d if isPrime) return p; isPrime-true Use your PrimeSequence class to generate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT