Skip to main content

Calculate Monthly Depreciation and Accumulation

1 reply [Last post]
Joined: 2013-09-17
Points: 0

i want to write a function which calculates the Monthly depreciation and accumulation of an asset but i am having difficulties writing it to calculate and insert it into mysql database.I will appreciate the help

private double getAccumulation(){
double Accumulation = 0;
double Monthly_Depreciation;
int Estimated_Useful_Life = Integer.parseInt(eul.getText());
double Cost_Of_Acquisition = Integer.parseInt(txt_coa.getText());
double Estimated_Residual_Value = Integer.parseInt(txt_erv.getText());
Monthly_Depreciation = (Cost_Of_Acquisition - Estimated_Residual_Value)/Estimated_Useful_Life;
Accumulation = Monthly_Depreciation;
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
return Accumulation;

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-08-30
Points: 0

Hi bankTechy

What part isn't working?

Are your variables being correctly pulled in from the UI? Is the Accumulation result incorrect? Is the database part done but not writing any values?

Also, a tip on code style, don't mark the variable names beginning with a capital letter. Eg make Estimated_Useful_Life, estimatedUsefulLife, Cost_Of_Acquisition, costOfAcquisition, Monthly_Deprecation, monthlyDeprecation

Although it wont have too big an impact on your program, the reason being is that classes start with a capital letter, eg Integer, JOptionPane, Exception whilst variable names (such as accumulation) and methods, getAccumulation(), don't. It just makes it easier to read and for other developers to coloborate on your code with.

Good luck