Page 1 of 2 12 LastLast
Results 1 to 20 of 35
Like Tree2Likes

Thread: Java Assignment

  1. #1
    MichaelF144 is offline Member
    Join Date
    Apr 2012
    Posts
    18
    Rep Power
    0

    Default Java Assignment

    Hey guys, struggling with Java eclipse programming and am in need of some assitance for this question, anything would be great.


    2. Consider the following skeleton of the program:

    public class Calculator {
    public static void main(String[] args) {
    Investment i1 = new Investment(100, 7.5, 10);
    Investment i2 = new Investment(200, 5);
    Investment i3 = new Investment();
    i1.calculateFutureValue();
    i2.calculateFutueValue();
    i3.calculateFutureValue();
    }
    }


    public class Investment{
    }

    Investment(){
    }
    Investment(double mthlyInvest, double rate, double time) {
    }
    Investment(double mthlyInvest, double rate){
    }
    Public void calculateFutureValue(){
    }


    Your task is to complete the Investment class:
    1. Default constructor will take the monthly investment, rate and years from user.
    2. Parameterized constructors will accept these values as arguments.
    3. for calculating future value,
    a. The rate of interest must be changed to monthly rate of interest.
    For example: 7.5% interest
    Monthly interest = 0.75/12;
    b. The number of years must be changed to number of months.
    For example: 10 years
    Number of months = 10 * 12 = 120 months
    4 To calculate the future value use the following formula to given number of months (Hint: use of
    loops):

    futureValue = (futureValue + monthlyInvestment)*(1 + MonthlyInterest)
    5. Make use of access modifiers, Accessors and mutators where required.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: Java Assignment

    What have you done so far and where are you stuck?
    Include full error messages and stack traces, indicating where in your code the problem lies.

    Also, please use [code] tags [/code] when posting code.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    MichaelF144 is offline Member
    Join Date
    Apr 2012
    Posts
    18
    Rep Power
    0

    Default Re: Java Assignment

    import java.util.Scanner;

    public void calculateFutureValue(){


    Im unsure how to continue on at all, im mind blanked

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: Java Assignment

    Odd place to start.
    Start at point 1, with the constructor.

    And use code tags, or I'm out of here.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    MichaelF144 is offline Member
    Join Date
    Apr 2012
    Posts
    18
    Rep Power
    0

    Default Re: Java Assignment

    what u mean code tags or your out of here?

  6. #6
    jlczuk is offline Senior Member
    Join Date
    Apr 2012
    Location
    New York State of Confusion, USA
    Posts
    137
    Blog Entries
    1
    Rep Power
    0

    Default Re: Java Assignment

    I think the OP has no clue how to define a class and is overwhelmed by the list, rather than just starting with figuring out the basics and doing point 1 as you've suggested Tolls.

    Perhaps the OP should start by reading the Java Classes Tutorial to understand the basics of creating a class. Hint: A constructor is just a special kind of method.

  7. #7
    MichaelF144 is offline Member
    Join Date
    Apr 2012
    Posts
    18
    Rep Power
    0

    Default Re: Java Assignment

    thanks for tryng guys ill see if anyone else knows what to do

  8. #8
    jlczuk is offline Senior Member
    Join Date
    Apr 2012
    Location
    New York State of Confusion, USA
    Posts
    137
    Blog Entries
    1
    Rep Power
    0

    Default Re: Java Assignment

    You don't need to go anywhere, just listen to what you're told and if you don't understand, just ask.

    What Tolls means is whenever you post java code using special tags so your java code will look like this:

    Java Code:
    class YourCodeGoesHere {
        private int myPrivateIntAttribute;
        
        public void myPublicMethod()  {
            myPrivateIntAttribute = 42;  // The answer to the ultimate question about life, the universe and everything.
        }
    }
    You do this by wrapping your Java in the "code" tags that Tolls included in his original reply.

  9. #9
    MichaelF144 is offline Member
    Join Date
    Apr 2012
    Posts
    18
    Rep Power
    0

    Default Re: Java Assignment

    oh i get you now and that should come up in green on my program.

    Ok so help me with part one this is what i reckon so far.

    import java.util.Scanner;

    // then i need to work out the monthly investment and rate of the user

    im really not sure how to do the next few lines

  10. #10
    MichaelF144 is offline Member
    Join Date
    Apr 2012
    Posts
    18
    Rep Power
    0

    Default Re: Java Assignment

    i knoe how much use dislike giving out codes, i just need some help i really struggle at this subject

  11. #11
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: Java Assignment

    Quote Originally Posted by MichaelF144 View Post
    i knoe how much use dislike giving out codes, i just need some help i really struggle at this subject
    You've been given a link to a tutorial. Did you read it? If so, what didn't you understand? You were also asked to use code tags, which you have not done (although your "code" is barely one line, it's the thought that counts). You have to put forth some effort. Read the tutorial you were linked to, and ask a specific question about what you don't understand.

    You're going to have to forget about the assignment for a second and go back to the basics. Can you write a hello world program as a starter shell?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  12. #12
    jlczuk is offline Senior Member
    Join Date
    Apr 2012
    Location
    New York State of Confusion, USA
    Posts
    137
    Blog Entries
    1
    Rep Power
    0

    Default Re: Java Assignment

    Please understand that we are not going to do your work for you. We are going to ask a lot of questions to get you to think about how you can do your work for yourself. We will point out silly errors and link you to information that helps you learn.

    1. Default constructor will take the monthly investment, rate and years from user.

    Do you know which is your default constructor? Do you understand that you have to obtain the three inputs from the person that runs your program? You can use this example to read input from a user, it reads into the byte[] you pass as the parameter. You can then create a String from that byte[].

    Java Code:
    try {
    	byte[] buffer = new byte[100];
    	System.in.read(buffer);
    	String s = new String(buffer);
    } catch (IOException e1) {
    	e1.printStackTrace();
    }

  13. #13
    MichaelF144 is offline Member
    Join Date
    Apr 2012
    Posts
    18
    Rep Power
    0

    Default Re: Java Assignment

    class HelloWorld {
    public static void main(String[] args)
    {
    System.out.println("Hello World!");
    }
    }


    i just dont know how to continue the program at all

  14. #14
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default Re: Java Assignment

    Quote Originally Posted by MichaelF144 View Post
    i just dont know how to continue the program at all
    Okay, so rereading the post, you were already supplied a skeleton code. What's the very next thing you know you have to do? Don't worry about the whole list, just break it down into smaller pieces and concentrate on one small piece at a time.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  15. #15
    MichaelF144 is offline Member
    Join Date
    Apr 2012
    Posts
    18
    Rep Power
    0

    Default Re: Java Assignment

    the very next thing i need to do would be part one of the assignment.
    1. Default constructor will take the monthly investment, rate and years from user.

    so i need to write a code which involves the compouned interest rate, or so i think

  16. #16
    jlczuk is offline Senior Member
    Join Date
    Apr 2012
    Location
    New York State of Confusion, USA
    Posts
    137
    Blog Entries
    1
    Rep Power
    0

    Default Re: Java Assignment

    Correct. From reading your original post, I believe you already defined that constructor, it is empty though. Now you have to fill in the method body.

  17. #17
    MichaelF144 is offline Member
    Join Date
    Apr 2012
    Posts
    18
    Rep Power
    0

    Default Re: Java Assignment

    so see how i provided the skeleton what i basically need to do is fill in the values?

  18. #18
    jlczuk is offline Senior Member
    Join Date
    Apr 2012
    Location
    New York State of Confusion, USA
    Posts
    137
    Blog Entries
    1
    Rep Power
    0

    Default Re: Java Assignment

    You have to get the values from the user as I described in my previous post and you have to store them in the instance variables for your class.

  19. #19
    MichaelF144 is offline Member
    Join Date
    Apr 2012
    Posts
    18
    Rep Power
    0

    Default Re: Java Assignment

    so these values 7.5% interest
    Monthly interest = 0.75/12;
    10 years

  20. #20
    jlczuk is offline Senior Member
    Join Date
    Apr 2012
    Location
    New York State of Confusion, USA
    Posts
    137
    Blog Entries
    1
    Rep Power
    0

    Default Re: Java Assignment

    Well, I imagine that 7.5% interest will be a float. Your monthly interest is incorrect though. How do you represent 7.5% as a decimal value?

Page 1 of 2 12 LastLast

Similar Threads

  1. java assignment
    By drewjordan in forum New To Java
    Replies: 9
    Last Post: 01-15-2012, 11:44 PM
  2. Java Assignment Help
    By nve5009 in forum New To Java
    Replies: 4
    Last Post: 04-27-2011, 06:36 AM
  3. Need Help with Java Assignment
    By smurf67 in forum New To Java
    Replies: 4
    Last Post: 03-26-2011, 10:25 AM
  4. Help me please (Java assignment)
    By cris_carriaga in forum Java Applets
    Replies: 4
    Last Post: 10-06-2010, 04:11 PM
  5. My java assignment -- please help me !
    By java_beginner1 in forum New To Java
    Replies: 11
    Last Post: 05-20-2010, 04:00 PM

Posting Permissions

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