using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace project5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void btnCompute_Click(object sender, EventArgs e)
{
float p;
float r;
double total;
int n = 1;
p = float.Parse(txtPrincipal.Text);
r = float.Parse(txtAunnalInteretRate.Text);
total = p * (Math.Pow((1 + r), n) - 1) * (1 + r) / r;
if (total < 1000000)
{
n = n + 1;
total = p * (Math.Pow((1 + r), n) - 1) * (1 + r) / r;
}
else
{
txtYear.Text = n.ToString();
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace project5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void btnCompute_Click(object sender, EventArgs e)
{
float p;
float r;
double total;
int n = 1;
p = float.Parse(txtPrincipal.Text);
r = float.Parse(txtAunnalInteretRate.Text);
total = p * (Math.Pow((1 + r), n) - 1) * (1 + r) / r;
if (total < 1000000)
{
n = n + 1;
total = p * (Math.Pow((1 + r), n) - 1) * (1 + r) / r;
}
else
{
txtYear.Text = n.ToString();
}
}
}
}
//这样看看
if (total < 1000000)
{
n = n + 1;
total = p * (Math.Pow((1 + r), n) - 1) * (1 + r) / r;
txtYear.Text = total.ToString(); //加上这句再看看
}
else
{
txtYear.Text = n.ToString();
}
if (total < 1000000)
{
n = n + 1;
total = p * (Math.Pow((1 + r), n) - 1) * (1 + r) / r;
textBox3.Text = total.ToString();
}
else
{
textBox3.Text = n.ToString();
}