For the first program, we\'re going to do some minimal proces functional decompo
ID: 3881955 • Letter: F
Question
For the first program, we're going to do some minimal proces functional decomposition. sing using iteration, selection, Assignment Problem: A customer has $1,000,000 at his bank account and he wants to buy a new house. But since the new house price may be more or less than $1,000,000 so there are only three situations The house costs less than a million and the user just want to withdraw the amount from his account. a. b. The house costs more than a million and fortunately the customer has that money in cash and he just want to deposit it. The house costs more than a million, but the customer does not have that money so he needs to take a loan from the bank and then calculates the interest. c. Practical solution: You have to make a program option contains a function call. Since you have three options, so you have to write three functions that asks the user about what option he wants to go with. Each 1-Withdraw function: will ask the user about the amount he wants to withdraw from the account. He cannot withdraw more than what he/she currently have in their account and should receive an error message if he tries to do so. Confirm transaction to user with the amount withdrawn and the amount remaining in his balance 2- Deposit function: wil ask the user about the amount of money to be deposit to the account, and the code should confirm the transaction with the amount deposited and the new balance 3- Credit score function: To get a cash loan from bank, the bank needs to check the user's credit score such that it can calculate the interest rate If the credit score is below or equal to 500 then the annual interest rate is 5%, if it is between 501 and 700, the annual interest rate will be 2%, otherwise the annual he program will ask the user for the number of month to pay off the loan. Depending on number of months and the credit score, the bank will interest rate will be 1%. T calculate the payment for user for each month using the following formula (P)(1+r)n/12 Where P is the loan, r is the annual interest rate and n is the number of months After each transaction, the program should check if the user wants to perform any other transaction or if he/she is done.Explanation / Answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankLoan
{
public class Customer
{
public Customer(double balance)
{
this.AvailableBalance = balance;
}
public double AvailableBalance
{
get;
set;
}
public void AccountBalance()
{
Console.WriteLine("Your account holds : " + this.AvailableBalance);
}
public void WithDrawAmount(double amount)
{
this.AvailableBalance = this.AvailableBalance - amount;
}
public void DepositeAmount(double amount)
{
this.AvailableBalance = this.AvailableBalance + amount;
}
public double MonthlyPayment(double principle, double interest, int term)
{
interest /= 100.0;
Console.WriteLine("Principle : " + principle + " terms : " + term);
Console.WriteLine();
double MonthlyPayment = (principle * (Math.Pow((1+interest), term/12))) / term ; //(principle*MonthlyRate) / (1-Math.Pow(1+MonthlyRate, - term));
return MonthlyPayment;
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("==============================================");
Console.WriteLine("Welcome to our System!");
Console.WriteLine("----------------------------------------------");
Console.WriteLine("1: Withdraw the cost from your account");
Console.WriteLine("2: Deposit to your account");
Console.WriteLine("3: Apply for a loan");
Console.WriteLine("4: Exit the System");
Console.WriteLine("==============================================");
Customer obj = new Customer(1000000);
obj.AccountBalance();
int choice;
do
{
Console.WriteLine("Please select the operation you would like to use: ");
Console.Write("Input: ");
choice = Convert.ToInt32(Console.ReadLine());
switch (choice)
{
case 1:
Console.WriteLine("Enter the amount you wish to withdraw");
double withdrawAmount = Convert.ToDouble(Console.ReadLine());
if (withdrawAmount > obj.AvailableBalance)
{
Console.WriteLine("You may not withdraw more than what you have.");
}
else
{
obj.WithDrawAmount(withdrawAmount);
obj.AccountBalance();
}
break;
case 2:
Console.WriteLine("Enter the amount you wish to Deposit");
string deposite = Console.ReadLine();
double number;
if (!Double.TryParse(deposite, out number))
{
Console.WriteLine("Enter only numbers");
}
obj.DepositeAmount(number);
obj.AccountBalance();
break;
case 3:
Console.WriteLine("Please enter you credit score");
string creditScore = Console.ReadLine();
double score;
if (!Double.TryParse(creditScore, out score))
{
Console.WriteLine("Enter only numbers");
}
Console.WriteLine("Please enter the loan size you would like to apply.");
string loanAmount = Console.ReadLine();
double loan;
if (!Double.TryParse(loanAmount, out loan))
{
Console.WriteLine("Enter only numbers");
}
Console.WriteLine("Please enter how many months you will pay the loan back.");
string termRequired = Console.ReadLine();
int term;
if (!Int32.TryParse(termRequired, out term))
{
Console.WriteLine("Enter only numbers");
}
double interest = 0;
if (score < 500)
{
interest = 5;
}
else if (score >= 501 && score <= 700)
{
interest = 2;
}
else
{
interest = 1;
}
Console.WriteLine("Monthly payment : " + obj.MonthlyPayment(loan, interest, term));
obj.AccountBalance();
break;
case 0:
Console.WriteLine("Thank you for using our system.");
Environment.Exit(0);
break;
default: Console.WriteLine("Enter proper input");
break;
}
} while (choice >= 0 && choice <= 3 );
}
}
}