コード例 #1
0
 private void HideAcctNumElements()
 {
     AccountNumberText.Hide();
     AcctNumTextBox.Hide();
     Warning.Hide();
     SubmitAcctNumButton.Hide();
     InterestEarned.Hide();
 }
コード例 #2
0
        private void btnCalculator_Click(object sender, EventArgs e)
        {
            {
                double Principal, AnnualRate, InterestEarned;

                double FutureValue, RatePerPeriod;

                int NumberOfPeriods, CompoundType;

                Principal  = Double.Parse(txtPrincipal.Text);
                AnnualRate = Double.Parse(txtInterest.Text) / 100;
                if (rdoMonthly.Checked)
                {
                    CompoundType = 12;
                }
                else if (rdoQuarterly.Checked)
                {
                    CompoundType = 4;
                }
                else if (rdoSemiannually.Checked)
                {
                    CompoundType = 2;
                }
                else
                {
                    CompoundType = 1;
                }

                NumberOfPeriods = Int32.Parse(txtPeriods.Text);

                double i = AnnualRate / CompoundType;

                int n = CompoundType * NumberOfPeriods;

                RatePerPeriod  = AnnualRate / NumberOfPeriods;
                FutureValue    = Principal * Math.Pow(1 + i, n);
                InterestEarned = FutureValue - Principal;

                txtInterestEarned.Text = InterestEarned.ToString("C");
                txtAmountEarned.Text   = FutureValue.ToString("C");
            }
        }
コード例 #3
0
        private void ViewInterestBtn_Click(object sender, EventArgs e)
        {
            if (ViewInterestBtn.Text == "View Interest Earned")
            {
                int yearCounter = Convert.ToInt32(YearsNum.Text.ToString());

                double interestEarned = (double)(MySavingsAccount.Balance * (yearCounter *
                                                                             MySavingsAccount.InterestRate));

                InterestEarned.Text = $"${interestEarned.ToString()}";

                ViewInterestBtn.Text = "Reset";
                HideInterestButtons();
                InterestEarned.Show();
            }
            else if (ViewInterestBtn.Text == "Reset")
            {
                InterestEarned.Hide();
                ShowInterestButtons();
                ViewInterestBtn.Text = "View Interest Earned";
            }
        }