using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-us");
double loanAmount = readPositiveDouble("Enter principal loan amount: ");
double rate = readPositiveDouble("Enter rate of interest per month (percents 0...100): ");
double tenure = readPositiveDouble("Enter tenure of the loan in months: ");
loanAmount += loanAmount * (rate / 100) * tenure;
Console.WriteLine("Final sum to pay: {0}\nPress any key to continue...", loanAmount.ToString("F3"));
Console.ReadKey();
}
static double readPositiveDouble(string prompt)
{
double result = 0;
do
{
Console.Write(prompt);
} while (!Double.TryParse(Console.ReadLine(), out result) || result <= 0);
return result;
}
}
}
Comments
Leave a comment