I am new to programming and "programming thinking" as well. I have created a simple program that calculates future earnings from investing. It seems to be working correctly, but I want to be sure and ask some smarter guy out here, whether the program is really working as it should or whether it could be written in a better and cleaner form. Input in first month is 15000, Other months: 1000, End of time period, when I want to see the earnings: 72 months, growth/month: 0.75 %; Each new input grows every month by its 0.75 %
static void Main(string[] args)
{
double inpInt, inpMonth, inpMonthTrue, growMonth, monthCount, sum, inpTotal, earnTotal;
inpInt = 15000;
inpMonth = 0;
inpMonthTrue = 1000;
growMonth = 0.75;
monthCount = 72;
inpTotal = inpInt + inpMonthTrue * (monthCount - 1);
sum = inpInt + inpMonth;
inpInt += inpInt / 100 * 0.75;
monthCount--;
Console.WriteLine("Value in months:" );
Console.WriteLine(inpInt);
for (int i = 0; i < monthCount; i++)
{
inpMonth += inpMonthTrue;
inpInt += inpInt / 100 * growMonth;
inpMonth += inpMonth / 100 * growMonth;
sum = inpInt + inpMonth;
Console.WriteLine(sum);
}
earnTotal = sum - inpTotal;
Console.WriteLine(String.Format("Total input: {0}", inpTotal));
Console.WriteLine(String.Format("Total value: {0}", sum));
Console.WriteLine(String.Format("Total earnings: {0}", earnTotal));
Console.ReadLine();
}
Thanks
15000 ÷ (100 * 0.75) = 200
OR(15000 ÷ 100) x 0.75 = 112.5
? as both have different results. if the correct result is the first one, then your calculation is invalid. \$\endgroup\$