Expand|Select|Wrap|Line Numbers
- public class LabTest1Initialize
- {
- public static void main(String[] args)
- {
- // declare an integer (array) array with 6 rows (6 assets)
- // & 5 columns (5 attributes for each asset)
- int assetInfo[][] = new int [6][5];
- // populate the first row with asset#100 information
- assetInfo[0][0] = 100; //asset number
- assetInfo[0][1] = 3000; //acquisitionCost
- assetInfo[0][2] = 300; //approximateSalvageValue
- assetInfo[0][3] = 6; //numberOfYearsUsefulLife
- assetInfo[0][4] = 1; //deprecationMethod
- // populate the second row with asset#101 information
- assetInfo[1][0] = 101; //asset number
- assetInfo[1][1] = 25000; //acquisitionCost
- assetInfo[1][2] = 1000; //approximateSalvageValue
- assetInfo[1][3] = 3; //numberOfYearsUsefulLife
- assetInfo[1][4] = 2; //deprecationMethod
- // populate the third row with asset#102 information
- assetInfo[2][0] = 102; //asset number
- assetInfo[2][1] = 9000; //acquisitionCost
- assetInfo[2][2] = 500; //approximateSalvageValue
- assetInfo[2][3] = 5; //numberOfYearsUsefulLife
- assetInfo[2][4] = 1; //deprecationMethod
- // populate the fourth row with asset#103 information
- assetInfo[3][0] = 103; //asset number
- assetInfo[3][1] = 7500; //acquisitionCost
- assetInfo[3][2] = 1500; //approximateSalvageValue
- assetInfo[3][3] = 7; //numberOfYearsUsefulLife
- assetInfo[3][4] = 2; //deprecationMethod
- // populate the fifth row with asset#104 information
- assetInfo[4][0] = 104; //asset number
- assetInfo[4][1] = 21000; //acquisitionCost
- assetInfo[4][2] = 1000; //approximateSalvageValue
- assetInfo[4][3] = 6; //numberOfYearsUsefulLife
- assetInfo[4][4] = 2; //deprecationMethod
- // populate the sixth row with asset#105 information
- assetInfo[5][0] = 105; //asset number
- assetInfo[5][1] = 22000; //acquisitionCost
- assetInfo[5][2] = 2000; //approximateSalvageValue
- assetInfo[5][3] = 5; //numberOfYearsUsefulLife
- assetInfo[5][4] = 3; //deprecationMethod
- // loop does rows one at a time for each asset
- for(int row = 0; row <= 5; row++)
- {
- int assetNumber = assetInfo[row][0];
- double acquisitionCost = assetInfo[row][1];
- double salvageValue = assetInfo[row][2];
- double numberOfYears = assetInfo[row][3];
- int depreciationMethod = assetInfo[row][4];
- System.out.println (" asset number = " + assetNumber);
- System.out.println (" acquisition cost of asset = " + (int)acquisitionCost);
- System.out.println (" salvage value = " + (int)salvageValue);
- System.out.println (" number of years = " + (int)numberOfYears);
- System.out.println (" depreciation method = " + depreciationMethod);
- // switch statement (page 51 in book) checks for depreciation method
- for(int y=1; y<=3 ; y++)
- switch (depreciationMethod)
- {
- case 1: System.out.println (" straight line depreciation ");
- double StraightLineDepreciation = ((acquisitionCost-salvageValue)/numberOfYears);
- double AccumulatedDeprecaitionSL = (StraightLineDepreciation*y);
- System.out.println ("Asset number " + assetNumber + " uses straight line depreciation");
- System.out.println (" depreciation charge for asset number " + assetNumber + " in year " + y + "=" + StraightLineDepreciation);
- System.out.println ("accumulated depreciation is " + AccumulatedDeprecaitionSL);
- break;
- case 2: System.out.println (" sum of years digits depreciation ");
- int SumofYears = ()
- break;
- case 3: System.out.println ("double declining balance depreciation ");
- double DDBDepreciation = ((BookValue-salvageValue)*2.0/(numberOfYears-y));
- double AccumulatedDepreciationDDB = (DDBDepreciation*y);
- System.out.println("Asset number " + assetNumber + " uses double declining balance depreciation");
- System.out.println (" depreciation charge for asset number " + assetNumber + " in year " + y + "=" + DDBDepreciation );
- System.out.println ("accumulated depreciation is " + AccumulatedDepreciationDDB);
- break;
- }
- System.out.println (); // print a blank line
- } // end of loop for each asset
- }
- }