You are on page 1of 3

usefulthing3

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PRG521_FA1_RentOrOwn
{
internal class Program
{
static void Main(string[] args)
{
Console.Write("====Welcome to the Rent or Buy Property calculator
Application!==== \n " +
"Please enter your full name: ");

String name = Console.ReadLine();

Console.WriteLine("\n");

Console.WriteLine("=====Hi " + name + "!=====" +


"\n" +
"\n");

Console.Write("Please Enter your Gross Salary here: R");

double grossSalary;

while (!double.TryParse(Console.ReadLine(), out grossSalary))


{
Console.Write("Invalid input. Please enter an numeric value: R");
}

Console.Write("\n" + "Alright, what is your estimated tax deductions:


R");

double taxDeduct;

while (!double.TryParse(Console.ReadLine(),out taxDeduct))


{
Console.Write("Invalid input, please enter a numeric value: R");
}

Console.Write("\n" + "Good, now how much would you say is your monthly
living expenses: R");

double livingExpense;

while (!double.TryParse(Console.ReadLine(), out livingExpense))


{
Console.Write("Invalid input, please enter a numeric value: R");
}

Console.WriteLine(" \n Alright that's good. Now, would you like to Rent


accommodation or would you like to Own Property?");
String rentOrOwn = Console.ReadLine();
double nettSalary = grossSalary - taxDeduct - livingExpense;

if (rentOrOwn == "Rent" || rentOrOwn == "rent")


{
Console.Write(" \n Alright, how much would you prefer to pay for
Rent monthly?: R");
double rentAmount;
while (!double.TryParse(Console.ReadLine(),out rentAmount))
{
Console.Write("Invalid input, please enter a numeric value:
R");
}
double nettSalaryRent = grossSalary - taxDeduct - livingExpense -
rentAmount;
Console.WriteLine("\n" + "Okay, with all this in mind, your nett
salary after all deductions will be R" + nettSalaryRent);
} else if (rentOrOwn == "Own" || rentOrOwn == "own")
{
Console.Write("\n" + "Awesome! what is the price of the home you're
looking to buy?: R");
double housePrice;
while (!double.TryParse(Console.ReadLine(),out housePrice))
{
Console.Write("Invalid input, please enter a numeric value:
R");
}

Console.Write("\n" + "Okay, please enter the amount you want to


deposit: R");
double depAmount;
while (!double.TryParse(Console.ReadLine(), out depAmount))
{
Console.Write("Invalid input, please enter a numeric value:
R");
}

Console.Write("\n" + "Okay good, what is the interest rate? In


PERCENTAGE PLEASE: ");
double interestRate;
while (!double.TryParse(Console.ReadLine(), out interestRate))
{
Console.Write("Invalid input, please enter a numeric value:
R");
}

Console.Write("\n" + "Alright almost there, now how long, in


months, do you plan to pay back the house?: ");
double repaymentTime;
while (!double.TryParse(Console.ReadLine(), out repaymentTime))
{
Console.Write("Invalid input, please enter a numeric value: ");
}

double monthlyPayment = (housePrice - depAmount) * (interestRate /


1200) / (1 - Math.Pow(1 + (interestRate / 1200), -repaymentTime));

String formattedMonthlyPayment = monthlyPayment.ToString("0.00");

Console.WriteLine("\n" + "Fantastic, your Monthly Payment will be


R" + formattedMonthlyPayment);

if (monthlyPayment > nettSalary/33.3)


{
Console.WriteLine("\nWARNING! The monthly loan payment is more
than one Third of your Nett Salary and The bank may not approve your loan!!");
} else
{
Console.WriteLine("\nAlright, everything looks good, your
chances of getting approved by the bank will be high, your nett salary with loan
included is R" + (nettSalary -= monthlyPayment));
}
}
}
}
}

You might also like