Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners recursion program
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


caritomerc
recursion program
0 Answer(s)      2 years and 9 months ago
Posted in : Java Beginners


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; 

}

}

Advertisement
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
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 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
Counter program for java
Counter program for java  The problem is to count from 000 to 444 with recursion. The maximum digit is 4 so that the program will count from 000,001,002,003,004,010, 011 and so on. How can I solve
program
program  any program of hotel or school management
program
program  write a program different between to dates in terms of days in java
program
program  write a html program in show table and this word in box
program
program  write a javascript program to create a application form with validation
program
program  program of jdbc using ms access for creating table
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
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   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
Advertisements
 

 

 

DMCA.com