Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 03-16-2009, 06:03 PM   #11
In Runtime
 
akira282's Avatar
 
Join Date: Mar 2009
Posts: 172
Default Re: Java project help

Yeah, I will in a bit. Do you think my two get methods are ok logically?

I think they are fine. For the getSYD he wants an (int year) in the parameter but isn't it possible to pull that info from asset.yearPurchased as well. I don't see why I need to do that.

Also, I'm stuck on the last getDDB.

public double getDDB(double bookvalue)

I think I may have to redo the SYD code too right? I mean doesn't it need the (int year) parameter hm.
__________________

akira282 is offline   Reply With Quote
Old 03-16-2009, 06:07 PM   #12
In Runtime
 
Daeva's Avatar
 
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: Java project help

Give me a moment to stew over this (about 20-30 minutes while I drive home from work) and then I'll be back. I have a couple ideas about the logic behind this.
__________________

__________________
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Old 03-16-2009, 06:07 PM   #13
In Runtime
 
akira282's Avatar
 
Join Date: Mar 2009
Posts: 172
Default Re: Java project help

public double getSYD(int year){
double SYD = asset.getBasis()*(asset.getLife()-year+1)/(asset.getLife()*(asset.getLife()+1)/2);
return SYD;
}

new formula

Ok, no prob

I'm stuck on the third one. hmm

Going to go eat

Conditionals need to look like this: <%
// TODO - perform conversion
String msg;
if (scale.equals("F")) {
msg = "Converted Temperature = " + df.format(tc.getCelsius()) + " degrees Celsius";
} else {
msg = "Converted Temperature = " + df.format(tc.getFahrenheit()) + " degrees Fahrenheit";
}
%>

I'm back at it.

Well, I'm stuck. What do you think I should do for the third get method: getDDB?
akira282 is offline   Reply With Quote
Old 03-16-2009, 09:03 PM   #14
In Runtime
 
Daeva's Avatar
 
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: Java project help

Sorry it took so long for the reply, I wanted to make sure I fully understood this.
Ok, I set this project up to get a better understanding of the flow of it.

You have to keep track of the new book value for your output right? I'm assuming you're storing that in a variable. If you're not, try it, thats how I made it work. Then in DDB that is the value that you pass in as the double. Then, after you print the output for that row, subtract the new book value by calling the getDDB function again.

I won't give you the complete code listing (unless you really want it) but here is what I have in my getDepreciationTable function (note I don't have tomcat or any JSP web-server currently set up on my pc, so this is written as a console application).
Code:
    public String getDepreciationTable(String method) {
        String returnString = "";
        double returnValue = 0.0;
        NumberFormat nf = NumberFormat.getCurrencyInstance();
        double newBasis = asset.getBasis();
        switch(method.charAt(1)) {
            case 'L':
                for(int i =0;i<asset.getLife();i++) {
                    newBasis -= getSLD();
                    returnString += (asset.getYearPurchased() + i+1) + "\t" + nf.format(getSLD()) + "\t" + (newBasis) + "\n";
                } // end for loop
                break;
            case 'Y':
                for(int i =0;i<asset.getLife();i++) {
                    newBasis -= getSYD(i+1);
                    returnString += (asset.getYearPurchased() + i+1) + "\t" + nf.format(getSYD(i+1)) + "\t" + newBasis + "\n";
                } // end for loop
                break;
            case 'D':
                for(int i =0;i<asset.getLife();i++) {
                    returnString += (asset.getYearPurchased() + i+1) + "\t" + nf.format(getDDB(newBasis)) + "\t" + newBasis + "\n";
                    newBasis -= getDDB(newBasis);
                } // end for loop
                break;
        } // end switch
        return returnString;
    } // end String getDepreciationTable
*EDIT: One question though. In his UML he doesn't define a getBasis, was this a typo on his part. I'll assume so, unless the instance variable basis is public.
__________________
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Old 03-16-2009, 09:17 PM   #15
In Runtime
 
akira282's Avatar
 
Join Date: Mar 2009
Posts: 172
Default Re: Java project help

The basis is a double, as it is the asset purchase price and the depreciation basis.

So can you explain again sorry how to get the third getmethod: getDDB ?

Also, this is what I am doing so far with the table method. What do you think?


public String getDepreciationTable(String method) {

NumberFormat cf = NumberFormat.getCurrencyInstance();
String msg = "";
if(method.equals("SL") )
{

for(int i=1; i<=asset.getLife();i++)
{

}
return msg;
}
if(method.equals("DDB"))
{
for(int i=1; i<=asset.getLife();i++)
}
return msg;

else
{
for(int i=1; i<=asset.getLife();i++)
}
return msg;

Can you tell me how to do the conditionals here. It makes most sense to me to do it here.

updated:

public String getDepreciationTable(String method) {

NumberFormat cf = NumberFormat.getCurrencyInstance();
String msg = "";
if(method.equals("SL") )
{

for(int i=1; i<=asset.getLife();i++)
{

}

}

else if(method.equals("DDB"))
{
for(int i=1; i<=asset.getLife();i++)
{
}
}


else if(method.equals("SYD") )
{
for(int i=1; i<=asset.getLife();i++)
{
}
}
return msg;

}
akira282 is offline   Reply With Quote
Old 03-16-2009, 09:35 PM   #16
In Runtime
 
Daeva's Avatar
 
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: Java project help

Both SLD and SYD deprecations are based on the initial value of the asset right? So when you are printing this out to match his output, you need to print the new book value as the last column right? To get that for SLD it looks like this:
30000.00 - 6000.00 = 240000.00
24000.00 - 6000.00 = 180000.00
18000.00 - 6000.00 = 120000.00
12000.00 - 6000.00 = 6000.00
6000.00 - 6000.00 = 0

So every time, you have to keep a running total of what the new book value is.

So, before my for loops, i created a new double variable to hold this value, and set it to the initial value of the asset.
Then, each time I go through the loop I subtract from this new double i created the amount of deprecation computed by the function (either SLD, SYD, or DDB).

The only difference with DDB, is that it computes the depreciation based on the previous years book value, not the starting book value of 30,000.00.

so, the DDB numbers look like this:
remember the first 12,0000 is double the book value divided by the useful life
so for the first time through the DDB function the numbers would look like this(using the numbers from his example):
(30,000.00 * 2)/5 = 12,000
Then you subtract this value (12,000) from the assets current value (30,000) in this case.
30,000.00 - 12,000.00 = 18,000.00
18,000.00 - 7,200.00 = 10,800.00
10,000.00 - 4,320 = 6,480.00
etc...

Does that make sense?
__________________
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Old 03-16-2009, 09:43 PM   #17
In Runtime
 
akira282's Avatar
 
Join Date: Mar 2009
Posts: 172
Default Re: Java project help

Yeah, that makes sense. Thanks for the help there.

Is it ok if I put the conditionals in the table method?

Thanks for all the help again. I will work on it. I probably will have some more questions:

returnString += (asset.getYearPurchased() + i+1) + "\t" + nf.format(getSLD()) + "\t" + (newBasis) + "\n";
} // end for loop

for this one you did: what does "\t" etc do?
akira282 is offline   Reply With Quote
Old 03-16-2009, 10:01 PM   #18
In Runtime
 
Daeva's Avatar
 
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: Java project help

Well, on the console \t puts a tab in.
And you're welcome for the help. I'm always happy to collaborate on a project like this.


for your example, you would want something like:
returnString += "<tr><td>" + (asset.getYearPurchased() +i+1) + "</td><td>" + nf.format(getSLD()) + "</td><td>" + newBasis + "</td></tr>";

Yes, I think the table method is the best place for them.
__________________
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Old 03-16-2009, 10:09 PM   #19
In Runtime
 
akira282's Avatar
 
Join Date: Mar 2009
Posts: 172
Default Re: Java project help

Ok, I got the SLD done. So .

I just have two more.

So for getDDB(double bookvalue)

I'll need to think about that a bit more. I'm working on the SYD.

I'll keep you posted. Thanks again for the help. I really appreciate it.

I may have a few more questions. I don't yet, but check back a bit later.

I guess one of the few questions remaining that i have is: when you insert a bookvalue in order to get a ddb, is that bookvalue the depreciation basis?
akira282 is offline   Reply With Quote
Old 03-16-2009, 10:44 PM   #20
In Runtime
 
Daeva's Avatar
 
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Thumbs up Re: Java project help

Sort of. The depreciation basis is the initial value of the asset. What you are passing into ddb is the initial value of the asset minus all previous depreciation AKA the new bookvalue.

Well, this is almost like a Chat, so I figured I'd let you know that I am going to turn in (I have an hour drive at 5:30 A.M to school... YAY ). I'll check back tomorrow morning (it's not due until wed right?) to see how things are going. Keep up the good work, you're a quick study. Good Luck, and happy programming!
__________________

__________________
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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



All times are GMT -5. The time now is 07:13 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0