java - Investing Calculator -
Hey I have created this code for compound interest during X years but I do not know how to save money Added "X amount of dollars per year is included." So if I make my variable $ 70,000, then this X amount will compound interest for the year, along with the starting amount of investment, "dollar amount every year".
Import java.util. *; // It is free to steal your code; honestly Minotaur, public sector investment {public static zero main (string [] args) {scanner input 1 = new scanner (System.in); Double amount; Double Principal; Double rate; System.out.println ("Please enter the principal"); Principal = Input 1 Nxt double (); System.out.println ("Please enter the interest rate in decimal rate"); Rate = input1.nextDouble (); System.out.println ("Enter the number of years of investment"); Scanner input 2 = new scanner (System.in); Int g = input2.nextInt (); (Int Year = 1; Year and LT; = G; Year ++) {Zodiac = Prime * Math (1 + rate, year); System.out.println (year + "+ + sum);}}}}
From the principal, instead of recomputing the value, the calculation from it last year:
zodiac = principal; (int year = 1; year
Then add only a sum to add a certain amount each year
zodiac = principals; (Int Year = 1; Year & lt; = g; Year ++) {Zodiac * = 1 + Rate; Zodiac + = & lt; To add amount & gt ;; System.out.println (year + "+ + zodiac);}
Comments
Post a Comment