Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By JosAH

Thread: Help

  1. #1
    hawk-dc is offline Member
    Join Date
    Nov 2013
    Posts
    22
    Rep Power
    0

    Default Help

    Hey here's the small project... but how can I return the value (amount) in 10 years ? The way I did, the program just doesnt return anything

    import java.util.Scanner;
    public class FutureValue
    {
    public static void main (String []args)

    {
    double amount = 0;
    double apr = 0;
    System.out.println("How much money would you like to invest?");
    Scanner kbd = new Scanner(System.in);
    amount = kbd.nextDouble();
    System.out.println("Your investment in 10 years will be: ");

    for (int i = 0 ; i < 10; i++)
    {
    amount = amount * (1 + apr);

    }

    }
    }

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,385
    Blog Entries
    7
    Rep Power
    20

    Default Re: Help

    A few remarks: the interest is 0% so after ten years, the invesment will be the same as when it started; you put all your code in the main( ... ) method; it's a void method so it can't return anything. hint: set apr to, say, 0.02 (2%)

    kind regards,

    Jos
    hawk-dc likes this.
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Help

    I think you meant no output when you said that it is not returning anything.
    So if you want output, you should add it. So after the for loop you could print the new amount with System.out.println.

    Kind regards,

    Konrad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •