小编Hib*_*ion的帖子

信用卡等式(C#中)

我有一个功课问题,我需要进行一些验证.我得到了问题第一部分的正确答案.然而,问题的第二部分并没有那么顺利.我不确定我的计算是否已关闭或测试数据是否错误.(今年已经发生了几次).

我们假设设计一个控制台应用程序,它将解决偿还贷款需要多少个月的时间.

我不能使用任何我还没有学过的代码; 只是基本代码.(没有循环,数组等)

公式为:N = - (1/30)*ln(1 + b/p(1-(1 + i)^ 30))/ ln(1 + i)

n =几个月

ln =日志功能

b =信用卡余额

p =每月付款

i =每日利率(年利率/ 365)

问题1的测试数据:

信用卡余额:5000美元

每月付款:200美元

年率:0.28

我的回答:38个月

问题2的测试数据:

信用卡余额:7500美元

每月付款:125美元

年费率:0.22

无法得到答案

我的解决方案

static void Main(string[] args)
{
    decimal creditcardbalance, monthlypayment;
    double calculation, months, annualpercentrate;

    Console.WriteLine("Enter the credit card balance in dollars and cents: ");
    creditcardbalance = decimal.Parse(Console.ReadLine());

    Console.WriteLine("Enter the monthly payment amount in dollars and cents: ");
    monthlypayment = decimal.Parse(Console.ReadLine()); …
Run Code Online (Sandbox Code Playgroud)

c# math

1
推荐指数
1
解决办法
1016
查看次数

标签 统计

c# ×1

math ×1