Connecting Tech Pros Worldwide Help | Site Map

calculating depreciation

Newbie
 
Join Date: Oct 2009
Posts: 1
#1: Oct 1 '09
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. }
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Oct 1 '09

re: calculating depreciation


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?
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#3: Oct 2 '09

re: calculating depreciation


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?
Reply