我有以下 C# 中简单控制台应用程序的代码。每当我输入第二个输入的 AIR 速率时,我都会得到“输入字符串格式不正确”作为错误。正确的格式是什么?如何将其合并到我制作的当前代码中?我不熟悉不同的变量类型。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int AIR, MIR, PMT, IP, PP, ABorrowed, Term;
Console.WriteLine("Please enter the amount borrowed on your loan ");
ABorrowed = int.Parse(Console.ReadLine());
Console.WriteLine("Please enter the interest rate for your loan ");
AIR = int.Parse(Console.ReadLine());
Console.WriteLine("Please enter term of your loan in months ");
Term = int.Parse(Console.ReadLine());
MIR = AIR / 1200;
PMT = ABorrowed * (MIR/1-(1/(1+MIR)^Term));
IP = ABorrowed * MIR;
PP = PMT - IP;
Console.WriteLine("Your total payment for this month is "+PMT);
Console.WriteLine("Of that payment " + IP + " is interest rate");
Console.WriteLine("and the Payment Portion is " + PP);
Console.ReadLine();
}
}
}