Results 1 to 20 of 35
Thread: Java Assignment
- 04-24-2012, 11:38 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 18
- Rep Power
- 0
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.
- 04-24-2012, 12:38 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
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.
- 04-24-2012, 12:48 PM #3
Member
- Join Date
- Apr 2012
- Posts
- 18
- Rep Power
- 0
Re: Java Assignment
import java.util.Scanner;
public void calculateFutureValue(){
Im unsure how to continue on at all, im mind blanked
- 04-24-2012, 01:41 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
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.
- 04-24-2012, 01:49 PM #5
Member
- Join Date
- Apr 2012
- Posts
- 18
- Rep Power
- 0
Re: Java Assignment
what u mean code tags or your out of here?
- 04-24-2012, 01:53 PM #6
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
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.
- 04-24-2012, 02:06 PM #7
Member
- Join Date
- Apr 2012
- Posts
- 18
- Rep Power
- 0
Re: Java Assignment
thanks for tryng guys ill see if anyone else knows what to do
- 04-24-2012, 02:25 PM #8
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
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:
You do this by wrapping your Java in the "code" tags that Tolls included in his original reply.Java Code:class YourCodeGoesHere { private int myPrivateIntAttribute; public void myPublicMethod() { myPrivateIntAttribute = 42; // The answer to the ultimate question about life, the universe and everything. } }
- 04-24-2012, 02:49 PM #9
Member
- Join Date
- Apr 2012
- Posts
- 18
- Rep Power
- 0
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
- 04-24-2012, 03:03 PM #10
Member
- Join Date
- Apr 2012
- Posts
- 18
- Rep Power
- 0
Re: Java Assignment
i knoe how much use dislike giving out codes, i just need some help i really struggle at this subject
- 04-24-2012, 03:17 PM #11
Re: Java Assignment
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!
- 04-24-2012, 03:22 PM #12
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
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(); }
- 04-24-2012, 03:24 PM #13
Member
- Join Date
- Apr 2012
- Posts
- 18
- Rep Power
- 0
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
- 04-24-2012, 03:33 PM #14
Re: Java Assignment
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 04-24-2012, 03:36 PM #15
Member
- Join Date
- Apr 2012
- Posts
- 18
- Rep Power
- 0
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
- 04-24-2012, 03:37 PM #16
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
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.
- 04-24-2012, 03:39 PM #17
Member
- Join Date
- Apr 2012
- Posts
- 18
- Rep Power
- 0
Re: Java Assignment
so see how i provided the skeleton what i basically need to do is fill in the values?
- 04-24-2012, 03:53 PM #18
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
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.
- 04-24-2012, 04:01 PM #19
Member
- Join Date
- Apr 2012
- Posts
- 18
- Rep Power
- 0
Re: Java Assignment
so these values 7.5% interest
Monthly interest = 0.75/12;
10 years
- 04-24-2012, 04:03 PM #20
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
Similar Threads
-
java assignment
By drewjordan in forum New To JavaReplies: 9Last Post: 01-15-2012, 11:44 PM -
Java Assignment Help
By nve5009 in forum New To JavaReplies: 4Last Post: 04-27-2011, 06:36 AM -
Need Help with Java Assignment
By smurf67 in forum New To JavaReplies: 4Last Post: 03-26-2011, 10:25 AM -
Help me please (Java assignment)
By cris_carriaga in forum Java AppletsReplies: 4Last Post: 10-06-2010, 04:11 PM -
My java assignment -- please help me !
By java_beginner1 in forum New To JavaReplies: 11Last Post: 05-20-2010, 04:00 PM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks