独習C#のP85で質問です。 ローン返済額を計算するプログラムですが、最後の Console.WriteLine("Payment is { 0:C} ", Payment); のところで以下エラーがでます。 「入力文字の形式が正しくありません。」 本の通り記述しているのですが、何ででしょうか? --以下コード-- private void button8_Click(object sender, EventArgs e) { decimal Principal; //元金 decimal IntRate; //decimal型の金利、たとえば0.075 decimal PayPerYear;//年間の支払い回数 decimal NumYears; //返済期間の年数 decimal Payment; //1回当たりの返済額 decimal numer, denom;//Pow()メソッド用の基数と指数 double b, g; Principal = 1500000.0m; IntRate = 0.075m; PayPerYear = 12.0m; NumYears = 5.0m; numer = IntRate * Principal / PayPerYear; g = (double) - (PayPerYear * NumYears); b = (double) (IntRate / PayPerYear) + 1; denom = 1 - (decimal) Math.Pow(b, g); Payment = numer / denom; Console.WriteLine("Payment is { 0:C} ", Payment); }
↧