473,320 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

calculating depreciation

I have an assignment to calculate depreciation using straight line, double declining balance and sum of the years digits. Heres what I have so far, but I can't seem to figure it out. Please help!!
Expand|Select|Wrap|Line Numbers
  1. public class LabTest1Initialize
  2. {
  3.     public static void main(String[] args)
  4.     {  
  5.  
  6.     // declare an integer (array) array with 6 rows (6 assets)  
  7.     // & 5 columns (5 attributes for each asset)
  8.         int assetInfo[][] = new int [6][5];
  9.  
  10.     // populate the first row with asset#100 information
  11.         assetInfo[0][0] = 100;        //asset number
  12.         assetInfo[0][1] = 3000;        //acquisitionCost
  13.         assetInfo[0][2] = 300;        //approximateSalvageValue 
  14.         assetInfo[0][3] = 6;        //numberOfYearsUsefulLife
  15.         assetInfo[0][4] = 1;        //deprecationMethod    
  16.  
  17.         // populate the second row with asset#101 information
  18.         assetInfo[1][0] = 101;        //asset number
  19.         assetInfo[1][1] = 25000;    //acquisitionCost
  20.         assetInfo[1][2] = 1000;        //approximateSalvageValue 
  21.         assetInfo[1][3] = 3;        //numberOfYearsUsefulLife
  22.         assetInfo[1][4] = 2;        //deprecationMethod    
  23.  
  24.         // populate the third row with asset#102 information
  25.         assetInfo[2][0] = 102;        //asset number
  26.         assetInfo[2][1] = 9000;        //acquisitionCost
  27.         assetInfo[2][2] = 500;        //approximateSalvageValue 
  28.         assetInfo[2][3] = 5;        //numberOfYearsUsefulLife
  29.         assetInfo[2][4] = 1;        //deprecationMethod    
  30.  
  31.         // populate the fourth row with asset#103 information
  32.         assetInfo[3][0] = 103;        //asset number
  33.         assetInfo[3][1] = 7500;        //acquisitionCost
  34.         assetInfo[3][2] = 1500;        //approximateSalvageValue 
  35.         assetInfo[3][3] = 7;        //numberOfYearsUsefulLife
  36.         assetInfo[3][4] = 2;        //deprecationMethod    
  37.  
  38.         // populate the fifth row with asset#104 information
  39.         assetInfo[4][0] = 104;        //asset number
  40.         assetInfo[4][1] = 21000;    //acquisitionCost
  41.         assetInfo[4][2] = 1000;        //approximateSalvageValue 
  42.         assetInfo[4][3] = 6;        //numberOfYearsUsefulLife
  43.         assetInfo[4][4] = 2;        //deprecationMethod    
  44.  
  45.         // populate the sixth row with asset#105 information
  46.         assetInfo[5][0] = 105;        //asset number
  47.         assetInfo[5][1] = 22000;    //acquisitionCost
  48.         assetInfo[5][2] = 2000;        //approximateSalvageValue 
  49.         assetInfo[5][3] = 5;        //numberOfYearsUsefulLife
  50.         assetInfo[5][4] = 3;        //deprecationMethod    
  51.  
  52.  
  53.  
  54.     // loop does rows one at a time for each asset
  55.         for(int row = 0; row <= 5; row++)
  56.         {
  57.         int assetNumber = assetInfo[row][0];
  58.         double acquisitionCost = assetInfo[row][1];
  59.         double salvageValue = assetInfo[row][2];
  60.         double numberOfYears = assetInfo[row][3];
  61.         int depreciationMethod = assetInfo[row][4]; 
  62.  
  63.  
  64.          System.out.println (" asset number = " + assetNumber);
  65.          System.out.println (" acquisition cost of asset = " + (int)acquisitionCost);
  66.         System.out.println (" salvage value = " + (int)salvageValue);
  67.         System.out.println (" number of years = " + (int)numberOfYears);
  68.          System.out.println (" depreciation method  = " + depreciationMethod);
  69.  
  70.         // switch statement (page 51 in book) checks for depreciation method
  71.  
  72.         for(int y=1; y<=3 ; y++)
  73.  
  74.         switch (depreciationMethod)
  75.             {
  76.  
  77.             case 1: System.out.println (" straight line depreciation ");
  78.                         double StraightLineDepreciation = ((acquisitionCost-salvageValue)/numberOfYears);
  79.                          double AccumulatedDeprecaitionSL = (StraightLineDepreciation*y);                                     
  80.                         System.out.println ("Asset number " + assetNumber + " uses straight line depreciation");
  81.                         System.out.println (" depreciation charge for asset number " + assetNumber + " in year " + y + "=" + StraightLineDepreciation);
  82.                         System.out.println ("accumulated depreciation is " + AccumulatedDeprecaitionSL);    
  83.                     break;
  84.             case 2: System.out.println (" sum of years digits depreciation ");
  85.                         int SumofYears = ()
  86.                     break;    
  87.             case 3: System.out.println ("double declining balance depreciation ");
  88.                         double DDBDepreciation = ((BookValue-salvageValue)*2.0/(numberOfYears-y));
  89.                         double AccumulatedDepreciationDDB = (DDBDepreciation*y);
  90.                         System.out.println("Asset number " + assetNumber + " uses double declining balance depreciation");
  91.                         System.out.println (" depreciation charge for asset number " + assetNumber + " in year " + y + "=" + DDBDepreciation );
  92.                         System.out.println ("accumulated depreciation is " + AccumulatedDepreciationDDB);
  93.                     break;    
  94.             }
  95.  
  96.             System.out.println (); // print a blank line
  97.         } // end of loop for each asset
  98.  
  99.  
  100.  
  101.     }
  102. }
Oct 1 '09 #1
2 6209
r035198x
13,262 8TB
Please use code tags if you have to post code.
Also, don't just dump your code here and say "I can't figure it out". What exactly can't you figure out. Does it compile? Where does it fail? Do you understand the depreciation method you are supposed to use?
Oct 1 '09 #2
Frinavale
9,735 Expert Mod 8TB
Well, reading through your nicely commented code everything looks fine....looks like it should work...

What is the problem you're having?
What can't you figure out?
Oct 2 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any...
0
by: Kasp | last post by:
Hi there, I am trying to make an OLAP cube on a table having two columns (datetime, Number_of_times_an_event_occured). My dimension is time and I want to measure the Min and Max times an event...
1
by: Joe Bongiardina | last post by:
What does the message "calculating...." mean in the lower left status area of a form? I have a form with no calculated, concatenated or lookup fields, yet it displays this msg. The form takes...
1
by: jlm | last post by:
I have a form which feeds table (TblEmpLeave) of Employee Leave Time (time taken off for Administrative, Annual, Sick, Compensation leave). I have EmpID, LeaveDate, LeaveType, LeaveHours fields on...
2
by: nejmay | last post by:
Help Please, I am taking a beginners VB.NET class and my next assignment making a Depreciation Calculator. I am suppose to use the built in functions SLN() and SYD() to perform the calus, option...
2
by: blagdam | last post by:
I am attempting to calculate the book value of assets in a query. I calculate total depreciation of the asset using the built in Strait Line Depreciation function and then use the following...
1
by: DaRok28 | last post by:
#include <iostream> using namespace std; int main() { int i, iYears; float fInitialVal, fSalvageVal; char cAgain; do
1
by: rjoseph | last post by:
Hi guys You've really helped me out in the past but now I really need your help! Basically I have a table (name=vehicletable) with the following fields/field data: Make Model Age ...
3
by: LosLobo | last post by:
Good morning all. This is my first post to the site, and what a wonderful site this is. I wish I had come across it years ago. I am working on a database that is going to track the assets for a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.