1.The user shall be able to enter the following values: a.Gross monthly income (before deductions). b.monthly tax deducted. c.monthly expenditures in each of the following categories: i.Groceries ii.Water and lights iii.Travel costs (including petrol) iv.Cell phone and telephone v. Other expenses 2.The user shall be able to choose between renting accommodation or buying a property. 3.If the user selects to rent, the user shall be able to enter the monthly rental amount. 4.If the user selects to buy a property, the user shall be required to enter the following values for a home loan:a.Purchase price of property. b.Total deposit. c.Interest rate (percentage). d.Number of months to repay (between 240 and 360) 5.The software shall calculate the monthly home loan repayment for buying a property based on the values that the user entered.6.If the monthly home loan repayment is more than a third of the user’s gross monthly income, the software shall alert the user that approval of the home loan is unlikely.
internal class Program
{
static void Main(string[] args)
{
double income = SetExpensenAndIncome();
SetAccommodation(income);
Console.ReadKey();
}
static void SetAccommodation(double income)
{
while (true)
{
Console.Write("Are you renting accommodationor buying:");
switch (Console.ReadLine())
{
case "renting":
{
Console.Write("Enter the monthly rental amount.");
Console.ReadLine();
return;
break;
}
case "buying":
{
Console.WriteLine("Enter the following values for a home loan");
Console.Write("Purchase price of property:");
double priceOfProperty = double.Parse(Console.ReadLine());
Console.Write("Total deposit:");
double totalDeposit = double.Parse(Console.ReadLine());
Console.Write("Interest rate (percentage):");
double rate = double.Parse(Console.ReadLine());
while (true)
{
Console.Write("Number of months to repay (between 240 and 360):");
int monthsToRepay = int.Parse(Console.ReadLine());
double monthlyHomeLoans = 0;
if (monthsToRepay >= 240 && monthsToRepay <= 360)
{
rate = rate / 100 / 12;
monthlyHomeLoans = (priceOfProperty - totalDeposit) * (rate * Math.Pow(1 + rate, monthsToRepay)
/ (Math.Pow(1 + rate, monthsToRepay) - 1));
if (monthlyHomeLoans > income / 3)
{
Console.WriteLine("Approval of the home loan is unlikely.");
return;
}
Console.WriteLine("Approval of the home loan is likely.");
return;
}
Console.WriteLine("Error. Enter again");
}
break;
}
default:
{
Console.WriteLine("You must enter whether renting or buying");
break;
}
}
}
}
static double SetExpensenAndIncome()
{
Console.WriteLine("Enter your expenses and income");
Console.Write("Gross monthly income (before deductions): ");
double income = double.Parse(Console.ReadLine());
Console.Write("Estimated monthly tax deducted: ");
Console.ReadLine();
Console.WriteLine("Estimated monthly expenditures in each of the following categories:");
Console.Write("Groceries: ");
Console.ReadLine();
Console.Write("Water and lights: ");
Console.ReadLine();
Console.Write("Travel costs (including petrol): ");
Console.ReadLine();
Console.Write("Cell phone and telephone: ");
Console.ReadLine();
Console.Write("Other expenses: ");
Console.ReadLine();
return income;
}
}
Comments
Leave a comment