recursion program

Ads
 

recursion program

Hi this is my first java class, and i have been trying for hours to do this program. it is a recursion problem where the user will enter a continuous monthly investment, at a rate of 1% the program should say how many months will it take to reach a million dollars plus return. any help would be appreciate it because i cant see what im doing wrong.

public class FinServiceCo

{
  public static void main(String[] args)

{
    StdOut.println("We are eager to help you reach your financial goals, that is why our 
company guarantees you a 1% monthly compounded return on your investments");

StdOut.println("How much money will you like to invest today?");

double money= StdIn.readDouble();//amount of money invested monthly

    double sum = Sum(money);//total amount of money after certain number of months

    double month = Month(money,sum);//calculates number of month for sum to reach 1 million dollar

StdOut.printf("after %.2f months",month);//prints out number of months

    StdOut.print("you have reached an amount of");

    StdOut.printf("%.2f",sum);//print out the sum of money

    StdOut.println();

    }
public static double Sum( double money)

{

   money = (money*0.01)+money;//increase the sum by 1 percent 

  if(money>=1000000)//if the sum is over million dollars then returns it to function call

    return money;

  else//else repeat function

  {  

    money=money+money;//increse a sum by amount invested monthly

    return money;//return sum

  }    



}

public static double Month( double money, double month)//function to calculate number of 
months to reach 1 million dollars

{

  money = money*1.01;//increase sum by 1 percent 

  month=month+1;//increse a month by one

  if(money>=1000000)//if statement if sum is more than 1 million dollar return number of 
months

    return month;

  else//else repeat function

  {

    money=money+money;//increse sum by money invested monthly

    month=Month( money, month);//repeat function

  }    

  return month; 

}

}
View Answers

Ads









Related Tutorials/Questions & Answers:
recursion program
recursion program  Hi this is my first java class, and i have been trying for hours to do this program. it is a recursion problem where the user will enter a continuous monthly investment, at a rate of 1% the program should say
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
Advertisements
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
java program to check whether a number is pallindrome or not using recursion???????
java program to check whether a number is pallindrome or not using recursion???????  java program to check whether a number is pallindrome or not using recursion
ModuleNotFoundError: No module named 'recursion'
ModuleNotFoundError: No module named 'recursion'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'recursion' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'dongjun_recursion'
ModuleNotFoundError: No module named 'dongjun_recursion'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'dongjun_recursion' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'dongjun_recursion'
ModuleNotFoundError: No module named 'dongjun_recursion'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'dongjun_recursion' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'hjc_recursion'
ModuleNotFoundError: No module named 'hjc_recursion'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'hjc_recursion' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'hjc_recursion'
ModuleNotFoundError: No module named 'hjc_recursion'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'hjc_recursion' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'python-recursion'
ModuleNotFoundError: No module named 'python-recursion'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'python-recursion' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'python-recursion'
ModuleNotFoundError: No module named 'python-recursion'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'python-recursion' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'python-recursion'
ModuleNotFoundError: No module named 'python-recursion'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'python-recursion' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'python-recursion'
ModuleNotFoundError: No module named 'python-recursion'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'python-recursion' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'Recursion-abhi'
ModuleNotFoundError: No module named 'Recursion-abhi'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Recursion-abhi' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'recursion-chintan'
ModuleNotFoundError: No module named 'recursion-chintan'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'recursion-chintan' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'recursion-detect'
ModuleNotFoundError: No module named 'recursion-detect'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'recursion-detect' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'recursion-visualiser'
ModuleNotFoundError: No module named 'recursion-visualiser'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'recursion-visualiser' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'recursion_xxx'
ModuleNotFoundError: No module named 'recursion_xxx'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'recursion_xxx' How to remove the ModuleNotFoundError: No module named
recursion
ModuleNotFoundError: No module named 'HS-recursion-List'
ModuleNotFoundError: No module named 'HS-recursion-List'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'HS-recursion-List' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'HS-recursion-List'
ModuleNotFoundError: No module named 'HS-recursion-List'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'HS-recursion-List' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'HS-recursion-List'
ModuleNotFoundError: No module named 'HS-recursion-List'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'HS-recursion-List' How to remove the ModuleNotFoundError: No module
javascript recursion example
javascript recursion example   javascript recursion example   <html> <script> function factorial (n) { if(n==0) return(1); return (n * factorial (n-1) ); } document.write(factorial(5)); <
XII STD RECURSION WITHOUT SCANNER
XII STD RECURSION WITHOUT SCANNER  the recursive function gives a stack overflow error. I want to calculate the GDC ie the greatest Integer function for two input numbers. the code of my program is as follows and the error comes
Calculate factorial Using Recursion
by using recursion in jsp. To make a program on factorial, firstly it must... a program on factorial by using recursion in jsp we are going to design a html page...Calculate factorial Using Recursion  
program
program  write a html program in show table and this word in box
program
program  write a program different between to dates in terms of days in java

Ads