Investment Calculator
807607Oct 24 2006 — edited Oct 24 2006I need to build a Investment Calculator with a driver. So far it will print out the initial deposit , rate and years. It will not return the values over a ten year period. I would appreciate any help. Here is the Invest Code:
import java.lang.Math;
/**
* Write a description of class InvestmentCalculator here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class InvestmentCalculator
{
// instance variables - replace the example below with your own
/**
* Constructor for objects of class InvestmentCalculator.
*/
public InvestmentCalculator()
{
}
public class value
{
InvestmentCalculator value = new InvestmentCalculator.InvestmentCalculator ();
}
public value Math (double value)
{
value = InitialDeposit * (1+rate)^10;
return value = 0.0;
}
/**
* An example of a method - replace this comment with your own.
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public InvestmentCalculator(double aInitialDeposit, int numberOfyears)
{
InitialDeposit = aInitialDeposit;
years = 0;
}
public InvestmentCalculator(float aRate)
{
rate = aRate;
}
public int hasMoreYears( int years)
{
return years;
}
public int advanceToNextYear()
{
return year;
}
public double getBalance()
{
return balance;
}
public void waitForBalance(double targetBalance)
{
while (balance < targetBalance)
{
years ++;
float arate = balance * rate/100;
balance = balance + rate;
}
}
private int year;
private int InitialDeposit;
private float InterestRate;
private int years;
private float balance;
private int rate;
}
Here is the Driver Code:
import java.util.Scanner;
/**
* Write a description of class InvestmentCalculatorDriver here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class InvestmentCalculatorDriver
{
// instance variables - replace the example below with your own
/**
* Constructor for objects of class InvestmentCalculatorDriver.
*/
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
InvestmentCalculator calculator = new InvestmentCalculator();
System.out.print("Enter initial deposit: ");
double aInitialDeposit = in.nextDouble();
System.out.print("Enter Interest rate: ");
float aInterestRate = in.nextFloat();
System.out.print("Enter number of years: ");
int numberOfyears = in.nextInt();
}
}