效果
![](https://img.haomeiwen.com/i14498479/0b243607612f6a37.png)
代码
static void Main(string[] args)
{
try
{
int p = 0;
Double a = 0;
Console.WriteLine("请输入本金");
p = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入年利率");
double r = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("请输入年数");
double n = Convert.ToDouble(Console.ReadLine());
a = p*Math.Pow(r + 1, n);
Console.WriteLine("年终金额为{0}", a);
}
catch
{
Console.WriteLine("输入有误请关闭重新输入");
}
Console.ReadKey();
}
}
}
网友评论