写了一个贷款计算器,感觉math.pow使用有误,因为输出的值和题目给出值不一样
如下为代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 贷款计算器
{
class Program
{
static void Main(string[] args)
{
double a, b, c, s;
Console.Write("贷款金额为:");
a = double.Parse(Console.ReadLine());
Console.Write("贷款月数为:");
b = double.Parse(Console.ReadLine());
Console.Write("贷款年利率为:");
c = double.Parse(Console.ReadLine());
double d, x, y,z,k;
d = c / 12;
z = a * d * (1 + d);
k = 1 + d;
x = Math.Pow(z,b);
y = Math.Pow(k,b);
y = y - 1;
s=x/y;
Console.Write("每月需还款:{0}", s);
}
}
}
变量本来没这么多的,后来我加了上去,只是为了测试,大神可无视。