英文:
What is the problem with this code? I'm new to programming and tried to solve this task about deposit calculations but I'm stuck at this for hours. C#
问题
using System;
namespace Deposit_calculator
{
internal class Program
{
static void Main(string[] args)
{
double depositedsum = double.Parse(Console.ReadLine());
double depositterm = double.Parse(Console.ReadLine());
double annualinterestpercentage = double.Parse(Console.ReadLine());
double sum = depositedsum + depositterm * ((depositedsum * annualinterestpercentage) / 12);
Console.WriteLine(sum);
}
}
}
这是你提供的代码部分。
英文:
using System;
namespace Deposit_calculator
{
internal class Program
{
static void Main(string[] args)
{
double depositedsum = double.Parse(Console.ReadLine());
double depositterm = double.Parse(Console.ReadLine());
double annualinterestpercentage = double.Parse(Console.ReadLine());
double sum = depositedsum + depositterm * ((depositedsum * annualinterestpercentage) / 12);
Console.WriteLine(sum);
}
}
}
I was supposed to get this answer: 202.85 using this input:200
3
5.7
The formula is: amount = deposited amount + term of the deposit * ((deposited amount * annual interest rate ) / 12)
答案1
得分: 1
根据已经评论的内容 - 百分比应该除以100,即:
using System;
namespace 存款计算器
{
internal class 程序
{
static void 主(string[] 参数)
{
double 存款金额 = double.Parse(Console.ReadLine());
double 存款期限 = double.Parse(Console.ReadLine());
double 年利率百分比 = double.Parse(Console.ReadLine()) / 100;
double 总额 = 存款金额 + 存款期限 * ((存款金额 * 年利率百分比) / 12);
Console.WriteLine(总额);
}
}
}
英文:
As per those that have already commented - percentage should be divided by 100, i.e.:
using System;
namespace Deposit_calculator
{
internal class Program
{
static void Main(string[] args)
{
double depositedsum = double.Parse(Console.ReadLine());
double depositterm = double.Parse(Console.ReadLine());
double annualinterestpercentage = double.Parse(Console.ReadLine()) / 100;
double sum = depositedsum + depositterm * ((depositedsum * annualinterestpercentage) / 12);
Console.WriteLine(sum);
}
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论