write in C# You will modify the banking application written in the Programming: Using Inheritance Assignment to throw an error during the data validations in the classes, rather than printing to the screen. This way the main application can decide on how to deal with the error without the application crashing. INSTRUCTIONS Based on the program you created for the Programming: Using Inheritance Assignment, modify your code to perform the following steps. In the Using Inheritance assignment, you created an Account hierarchy with a base class (Account) and two derived classes (SavingsAccount and CheckingAccount). Three of the mutator methods in this assignment validated user input: setBalance, setInterestRate, and setFeeCharged. In all of these methods, you were instructed to set the respective variables equal to zero if the user passed in a negative amount. In this assignment, you will modify your code such that if the user passes in a negative amount, an exception will be thrown that alerts the user that a negative amount has been entered. The program should catch the exception and display the error message to the user. Once an error (negative amount) has occurred, the program should inform the user that negative numbers are not permitted. It should then redisplay the menu. If an exception has not occurred, and a checking or savings object has been successfully created, the program should print the information for that object. [Hint: You will need to create an exception class – call it NegativeNumberException – that takes a string as an argument to its constructor that represents the error.
The string should be “Invalid Entry – Negative numbers are not permitted.”] Modify your Main() method such that instead of hardcoding the SavingsAccount and CheckingAccount information, you prompt the user to enter the needed information.
Generate a menu like the one below and loop until the user enters “Q” to quit the application.
here is code from current program that need to be modify, Need help Generate the Menu.
using System;
class Account
{
private decimal balance;
private string accountName;
private int accountNumber;
public Account(string name, int number, decimal initialBalance)
{
AccountName = name;
AccountNumber = number;
Balance = initialBalance;
}
public decimal Balance
{
get { return balance; }
set { balance = value >= 0 ? value : 0; }
}
public string AccountName
{
get { return accountName; }
set { accountName = value; }
}
public int AccountNumber
{
get { return accountNumber; }
set { accountNumber = value; }
}
public void Credit(decimal amount)
{
Balance += amount;
}
public bool Debit(decimal amount)
{
if (amount <= Balance)
{
Balance -= amount;
return true;
}
else
{
Console.WriteLine("Insufficient Funds.");
return false;
}
}
public virtual void PrintAccount()
{
Console.WriteLine($"Account Name: {AccountName}");
Console.WriteLine($"Account Number: {AccountNumber}");
Console.WriteLine($"Balance: ${Balance}");
}
}
class SavingsAccount : Account
{
private decimal interestRate;
public SavingsAccount(string name, int number, decimal initialBalance, decimal initialInterestRate)
: base(name, number, initialBalance)
{
SetInterestRate(initialInterestRate);
}
public decimal InterestRate
{
get { return interestRate; }
set { SetInterestRate(value); }
}
public void SetInterestRate(decimal rate)
{
interestRate = rate >= 0 ? rate : 0;
}
public decimal CalculateInterest()
{
return Balance * InterestRate;
}
public override void PrintAccount()
{
base.PrintAccount();
Console.WriteLine($"Interest Rate: {InterestRate}");
}
}
class CheckingAccount : Account
{
private decimal feeCharged;
public CheckingAccount(string name, int number, decimal initialBalance, decimal feeAmount)
: base(name, number, initialBalance)
{
SetFeeAmount(feeAmount);
}
public decimal FeeCharged
{
get { return feeCharged; }
set { SetFeeAmount(value); }
}
public void SetFeeAmount(decimal amount)
{
feeCharged = amount >= 0 ? amount : 0;
}
public override void PrintAccount()
{
base.PrintAccount();
Console.WriteLine($"Fee Charged: {FeeCharged}");
}
public new void Credit(decimal amount)
{
base.Credit(amount);
Balance -= FeeCharged;
}
public new bool Debit(decimal amount)
{
bool success = base.Debit(amount);
if (success)
{
Balance -= FeeCharged;
}
return success;
}
}
class Program
{
static void Main(string[] args)
{
// Create a new checking account object
CheckingAccount checkingAccount = new CheckingAccount("Smith Checking", 1, 1000m, 3.00m);
Console.WriteLine("Created checking account with $1,000 balance.");
Console.WriteLine();
// Create a new savings account object
SavingsAccount savingsAccount = new SavingsAccount("Smith Savings", 2, 2000m, 0.05m);
Console.WriteLine("Created savings account with $2,000 balance.");
Console.WriteLine();
}
}
example of correct program in picture.