to anyone, I'm new to using C# wrote a program for a business class to calculate double-decling balance method of depreciation for years.
But when I run the progam and enter the 2000 for property value, 5 for property life. I get the wrong results. for year 1 Value at Begining of year is 2000 is right but Depreciation during the year for year 1 shows 400 but its suppose to show 800, and in the total depreciation for end of year shows 400 but its suppose to show 800
for year 2 it shows 1600 Value at Begining of year but its suppose to be 1200.00, 2nd Column for Depreicaiton during the year shows 400 but its suppose to be 480.00 and for the Total depreciaiton to end of year is suppose to show 1280. But instead shows 800.
and the rest of the results is off.
Can anyone tell me if my code is wrong here

private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.ColumnCount = 4;
            dataGridView1.Columns[0].HeaderText = "Year";
            dataGridView1.Columns[1].HeaderText = "Value at Begining of Year";
            dataGridView1.Columns[2].HeaderText = "Depreciation During Year";
            dataGridView1.Columns[3].HeaderText = "Total depreciation to End of Year";
            double value, life, depreciation, totalDepreciation = 0;
            value = double.Parse(textBox1.Text);
            life = double.Parse(textBox2.Text);
            depreciation = value / life;
            dataGridView1.Rows.Clear();
            for (int year = 1; year <= life; year++)
            {
                dataGridView1.Rows.Add();
                dataGridView1.Rows[year - 1].Cells[0].Value = year;
                dataGridView1.Rows[year - 1].Cells[1].Value = value.ToString("c");
                dataGridView1.Rows[year - 1].Cells[2].Value = depreciation.ToString("c");
                totalDepreciation += depreciation;
                dataGridView1.Rows[year - 1].Cells[3].Value = totalDepreciation.ToString("c");
                value -= depreciation;

Recommended Answers

All 4 Replies

I dount we can help you out with this, maybe you didnt use the correct formulas for calculation. Code it self looks fine.

Tell us the exact formulas you use for calculating depreciation (the real formulas), maybe we can help you then...

The title of your thread is Double-Declining balance method of depreciation. The keyword is DOUBLE. This method of depreciation requires an annual accelerated interest rate. Thus, based on your title, how would you modify your annual interest rate?

Read this, it explains it well I believe.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.