Ejemplo n.º 1
0
        public void PPmtShouldCalculatedWithoutError(double rate, short period, short numberPeriods, double presentValue, double futureValue, DueDate due)
        {
            //Arrange
            var ppmt = new PPmt();

            //Act
            var exception = Record.Exception(() => ppmt.CapitalPayment(rate, period, numberPeriods, presentValue, futureValue, due));

            //Assert
            exception.Should().BeNull();
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                double trymonths;
                trymonths = double.Parse(textBox3.Text);
                if (trymonths < 6 || trymonths > 48)
                {
                    MessageBox.Show("Oops! We don't finance a vehicle for less than 6 months or more than 48 months!");
                }
                else
                {
                }
            }
            catch
            {
                MessageBox.Show("Oops! Enter the number of months to finance the vehicle for!");
            }

            dataGridView1.ColumnCount           = 5;
            dataGridView1.Columns[0].HeaderText = "Payment #";
            dataGridView1.Columns[1].HeaderText = "Monthly Payment";
            dataGridView1.Columns[2].HeaderText = "Amount to Interest";
            dataGridView1.Columns[3].HeaderText = "Amount to Principal";
            dataGridView1.Columns[4].HeaderText = "Remaining Balance";
            double cost, downpayment, months, rate, topayoff, PPmt, remaining, topayoff2;

            if (radioButton1.Checked)
            {
                rate = 0.069;
            }
            else
            {
                rate = 0.085;
            }
            cost        = double.Parse(textBox1.Text);
            downpayment = double.Parse(textBox2.Text);
            months      = double.Parse(textBox3.Text);
            topayoff    = cost - downpayment;
            topayoff2   = topayoff;
            dataGridView1.Rows.Clear();
            textBox4.Text = rate.ToString((rate) + "%");
            for (int payment = 1; payment <= months; payment++)
            {
                dataGridView1.Rows.Add();
                dataGridView1.Rows[payment - 1].Cells[0].Value = payment.ToString();
                dataGridView1.Rows[payment - 1].Cells[1].Value = Financial.Pmt(rate / 12, months, -topayoff2).ToString("C");
                dataGridView1.Rows[payment - 1].Cells[2].Value = Financial.IPmt(rate / 12, 1, months, -topayoff).ToString("C");
                PPmt = Financial.Pmt(rate / 12, months, -topayoff2) - Financial.IPmt(rate / 12, 1, months, -topayoff);
                dataGridView1.Rows[payment - 1].Cells[3].Value = PPmt.ToString("C");
                remaining = topayoff - PPmt;
                dataGridView1.Rows[payment - 1].Cells[4].Value = remaining.ToString("C");
                topayoff = remaining;

                if (payment % 2 == 0)
                {
                    dataGridView1.Rows[payment - 1].DefaultCellStyle.BackColor = Color.SkyBlue;
                }
                else
                {
                    dataGridView1.Rows[payment - 1].DefaultCellStyle.BackColor = Color.White;
                }
            }
        }