//Computer Programming Class
//Author: Seif Al Salem
import java.util.Scanner;
import java.text.DecimalFormat;
class CD {
public static void main(String[] args) {
double InitalInvestment;
double Interestrate;
double DesiredEndingValue;
// Decimal Format for the percent
DecimalFormat df = new DecimalFormat("#%");
// Scanner Input
Scanner scan = new Scanner (System.in);
// Inital Investment and the user input
System.out.print (" Please Enter the inital investment: ");
InitalInvestment = scan.nextDouble();
System.out.print (InitalInvestment);
// Interest Rate and the user input
System.out.print ("\n Pleae Enter Interest Rate: ");
Interestrate = scan.nextDouble();
Interestrate = Interestrate/100;
System.out.print (df.format (Interestrate));
// Desired Ending Value and the users input
System.out.print (" \n Please Enter Desired Ending Value: ");
DesiredEndingValue = scan.nextDouble();
System.out.print (DesiredEndingValue);
// loop, equation, and the year counter
int counter =0;
do {
InitalInvestment = InitalInvestment + (InitalInvestment * Interestrate);
counter++;
} while ( InitalInvestment < DesiredEndingValue);
// Output
System.out.println(" \n Number of years until desired value: " + counter + " years");
}
}