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 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









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 '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
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
recursion method - Ajax
recursion method  Can i ask for a program that input a lines in the diamond shape recursion method   Hi friend, Code for solving the problem : public class RecursiveDiamond { public RecursiveDiamond
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
recursion numbers - Java Beginners
recursion numbers  I need to use recursion to test all values from 0 to 20 and see if they are contain in a 1-D array with values: 2,4,6,8,10,12,14,16,18,20. The results of all numbers from 0-20 will be printed
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)); <
Recursion - Java Beginners
Recursion  Create a method called, rangeMult, that uses recursion to multiply a range of array elements. The method takes the following arguments...[] numbers = { 1, 2, 3, 4, 5 }; int sum; sum = rangeMult(numbers, 0, 2); The program
Recursion - Java Beginners
Recursion  HI!Can i ask for another recursion diamond,using recursive method and asking for how many lines should be inputed to create the diamond..., This is simple code of recursion code. public class RecursiveDemo { public static
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
Recursion - Java Beginners
Recursion  wr a program I/P: 3 O/P: 1 1 2 1 2 3 Using Recursive.   hey if you know the code plz
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  
Multiply a range of array elements using Recursion
Multiply a range of array elements using Recursion In this section you will learn how to use recursion to multiply a range of array elements. For this we have.... The program will return the product of the array elements that are within the range
program
program  any program of hotel or school management
program
program  program of jdbc using ms access for creating table
program
program  write a javascript program to create a application form with validation
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
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program   An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes
program
program  write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
program
program  Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder
program
program  explanation of program on extending thread class   Hi Friend, Please go through the following link:ADS_TO_REPLACE_1 Java Threads Thanks
program
program  Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
program
program  how to improve programming skills plss tell some tips..i am understanding concepts but unable to write program so,pls give some guideness plsss

Ads