Answer to Question #332826 in C# for DOHC 44

Question #332826

The user should enter the following values: Gross monthly income (before deductions) Estimated monthly tax deducted,Estimated monthly expenditures in each of the following categories,Groceries,Water and lights Travel costs (including petrol),Cell phone and telephone,Other expenses. 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 the property b. Total deposit c. Interest rate % 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 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. NB:MAKE USE OF GENERIC CLASSES


1
Expert's answer
2022-04-23T18:13:39-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


class Program
{
    static void Main()
    {
        Console.Write("Enter monthly income: ");
        decimal monthlyIncome = decimal.Parse(Console.ReadLine());


        Console.Write("Enter estimated montly tax: ");
        decimal monthlyTax = decimal.Parse(Console.ReadLine());


        Console.Write("Enter estimated monthly expenditures for groceries: ");
        decimal groceries = decimal.Parse(Console.ReadLine());


        Console.Write("Enter estimated monthly expenditures for water: ");
        decimal water = decimal.Parse(Console.ReadLine());


        Console.Write("Enter estimated monthly expenditures for lights: ");
        decimal lights = decimal.Parse(Console.ReadLine());


        Console.Write("Enter estimated monthly expenditures for traveling: ");
        decimal traveling = decimal.Parse(Console.ReadLine());


        Console.Write("Enter other expenses: ");
        decimal other = decimal.Parse(Console.ReadLine());


        Console.Write("Choose between renting accommodation (1) or buying a property (2): ");
        int choose = int.Parse(Console.ReadLine());


        decimal payment = monthlyIncome - monthlyTax - groceries - water - lights - traveling - other;


        if (choose == 0)
        {
            Console.Write("Enter the monthly rental amount: ");
            decimal rental = decimal.Parse(Console.ReadLine());


            if (payment / 3 < rental)
            {
                Console.WriteLine("Your income does not cover expenses!");
            }
        }
        else
        {
            Console.Write("Enter the purchase price of the property: ");
            decimal purchasePrice = decimal.Parse(Console.ReadLine());


            Console.Write("Enter total deposit: ");
            decimal deposit = decimal.Parse(Console.ReadLine());


            Console.Write("Enter interest rate(%): ");
            decimal rate = decimal.Parse(Console.ReadLine());


            Console.Write("Enter number of months to repay: ");
            decimal monthsToRepay = decimal.Parse(Console.ReadLine());


            decimal pricePerMonth = (purchasePrice * (rate / 100) + purchasePrice) / monthsToRepay + deposit;


            if(payment / 3 < pricePerMonth)
            {
                Console.WriteLine("Your income does not cover expenses!");
            }
        }
    }
}

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