Answer to Question #50522 in C# for Pooja

Question #50522
Dwayne manually calculates the interest rate using a calculator. However, he often commits
mistakes in calculating the interest due to the complex formula. Therefore, he asks Elina to build
an application that accepts the principal loan amount, rate of interest, and tenure of the loan and
calculates the EMI amount. Write the code that Elina should implement to create the applicatio
1
Expert's answer
2015-01-30T03:36:50-0500
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;
}
}
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS