Raj Chahil - ISYS 350 HW 6.docx - HW 6 PART 1 \u2013 Raj Chahil private void button1_Click(object sender EventArgs e dataGridView1.ColumnCount = 4

Raj Chahil - ISYS 350 HW 6.docx - HW 6 PART 1 u2013 Raj...

This preview shows page 1 - 3 out of 4 pages.

HW 6 PART 1 – Raj Chahil 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); dataGridView1.Rows.Clear(); for ( int year = 1; year <= life; year++) { dataGridView1.Rows.Add(); if (year < life) { depreciation = value * 2 / life; } else { depreciation = value; } 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; } HW 6 Part 1 Build
Image of page 1
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 4 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture