Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-30-2007, 02:34 PM
Member
 
Join Date: Jul 2007
Posts: 2
danny000 is on a distinguished road
Problem with Calculation ....
i need to calculate :

interest earned = invesment value (current) * (interest rate / 100)
invesment value (new) = invesment value (current) + interest earned

how do i write in a java program ?

is it ,
Code:
import java.util.scanner; public class invesment { public static void main (String [] args) { double intEarned = a; double inteValue = b; double newInves = c; Scanner keyboard = new Scanner(System.in); // this where we input the value System.out.print("Enter your Invesment Value:"); b = keyboard.nextDouble(); int i = 0; while (i < 5 ) { a = b * (10/100) c = b + a i = i + 1; } and so on.
my result must be like this :

year interest Earned Investment Value
---- --------------- -----------------
1 $10.00 $110.00
2 $11.00 $121.00
3 $12.10 $133.10
4 $13.31 $146.41
5 $14.64 $161.05

* how do i loop it ?
* is my calculation is correct ?

Thanks!

Last edited by danny000 : 07-30-2007 at 02:41 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-15-2008, 03:42 PM
Chris.Brown.SPE's Avatar
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); } } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +3. The time now is 07:59 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org