View Single Post
  #2 (permalink)  
Old 04-15-2008, 03:42 PM
Chris.Brown.SPE's Avatar
Chris.Brown.SPE Chris.Brown.SPE is offline
Member
 
Join Date: Apr 2008
Location: State College, PA
Posts: 50
Chris.Brown.SPE is on a distinguished road
Send a message via AIM to Chris.Brown.SPE
I'll be amazed if you are still looking for the answer to this problem. Hope this helps.

Code:
import java.util.*; public class investment { public static void main(String[] args) { double intEarned;// just use these for your variables, no a/b/c needed double inteValue;//you dont need newInves, just change inteValue. double interestRate = 10;// interest rate as variable so it is easier to // change int years = 5;// make the years an easily changed variable Scanner keyboard = new Scanner(System.in); // this where we input the value System.out.print("Enter your Invesment Value:"); inteValue = keyboard.nextDouble(); System.out.println("year interest Earned Investment Value"); System.out.println("---- --------------- -----------------"); for (int i = 0; i < years; i++) {// for loop controls the counter for you so you dont have to worry about it intEarned = inteValue * (interestRate / 100); inteValue = inteValue + intEarned; System.out.print((i + 1)); System.out.printf(" $%.2f", intEarned);// formated output for 2 decimal places System.out.printf(" $%.2f%n", inteValue); } } }
Reply With Quote