Question: C# program, please remember to include comments in your code and screenshot your output Create a window form application. The main form should be created
C# program, please remember to include comments in your code and screenshot your output
Create a window form application. The main form should be created as below.

Include the following details:
Create a base class named Account and derived classes named SavingsAccount and CheckingAccountthat inherit from class Account.
Base class Account should include one private instance variable of type decimal to represent the account balance. The class should provide a constructor that receives an initial balance and uses it to initialize the instance variable with a public property. The property should validate the initial balance to ensure that its greater than or equal to 0.0; if not throw an exception. The class should provide two public methods. Method Credit should add an amount to the current balance. Method Debit should withdraw money from the Account and ensure that the debit amount does not exceed the Accountsbalance. If it does, the balance should be left unchanged, and the method should display the message Debit amount exceeded the account balance. The class should also provide a get accessor in property Balance that returns the current balance.
Derived class SavingsAccount should inherit the functionality of an Account, but also include a decimal instance variable indicating the interest rate (percentage) assigned to the account.SavingsAccountsconstructor should receive the initial balance, as well as an initial value for the interest rate.SavingsAccountshould provide public method CalculateInterest that returns a decimal that indicates the amount of interest earned by an account. Method CalculateInterest should determine this amount by multiplying the interest rate by the account balance.[ Note : SavingsAccount should inherit methodsCreditand Debit without redefining them.]
Derived class CheckingAccount should inherit from base class Account and include a decimal instance variable that represents the fee charged per transaction. CheckingAccounts constructor should receive the accounts initial balance, as well as a parameter indicating a fee amount. Class CheckingAccount should redefine methods Credit and Debit so that they subtract the fee from the account balance whenever either transaction is performed successfully. CheckingAccounts version of these methods should invoke the base-class Account version to perform the updates to an account balance. CheckingAccounts Debitmethod should charge a fee only if money is actually withdrawn (i.e., the debit amount does not exceed the account balance). [Hint: Define Accounts Debit method so that it returns a bool indicating whether money was withdrawn. Then use the return value to determine whether a fee should be charged.]
After defining the classes in this hierarchy, write an app that creates objects of each class and tests their methods. Add interest to the SavingsAccount object by first invoking its CalculateInterest method, then passing the returned interest amount to the objects Credit method. Classes' examples related to this program below _____________________________________________________ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace ProjectName { public class Account { //private members private decimal balance;
//constructor public Account(decimal balance) { this.Balance = balance; }
public Account() {
}
//Getter and Setter for balance public decimal Balance { get { return balance; }
set { if (value >= 0) { balance = value; } else { MessageBox.Show("The Balance cannot be negative"); } } }
//Credit public virtual void Credit(decimal creditAmount) { if (creditAmount > 0) { Balance += creditAmount; } else { MessageBox.Show("You can only credit positive amounts to your account"); }
}
//Debit public virtual bool Debit(decimal debitAmount) { bool goodBalance = true; if (Balance - debitAmount > 0) { Balance -= debitAmount; goodBalance = true; } else { goodBalance = false; } return goodBalance; }
} }
_______________________________________
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace ProjectName { class CheckingAccount : Account { //private members private decimal transactionFee;
//constructor inherits balance from base class Account public CheckingAccount(decimal balance, decimal tFee) : base(balance) { this.TransactionFee = tFee;
}
public decimal TransactionFee { get { return transactionFee; } set { if (value > 0) { transactionFee = value; } else { MessageBox.Show("Fee cannot be less than Zero"); } }
} //CheckingAccount Overrrides Credit, subtracts the transaction fee public override void Credit(decimal creditAmount) { base.Credit(creditAmount); Balance -= TransactionFee; } //CheckingAccount Overrides Debit, subtracting the transaction fee public override bool Debit(decimal debitAmount) { if (base.Debit(debitAmount)) { Balance -= TransactionFee; return true; } else { MessageBox.Show("That will result in a negative balance"); return false; } }
public override string ToString() { return "Account type: Checking -- Balance: " + Balance + " -- Transaction Fee: " + TransactionFee; }
} } _________________________________________________________ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace ProjectName { class SavingsAccount : Account { //private members private decimal interestRate;
//Constructor public SavingsAccount(decimal balance, decimal interestRate) : base(balance) { this.InterestRate = interestRate; }
public decimal InterestRate { get { return interestRate; } set { if (value > 0) { interestRate = value; } else { MessageBox.Show("Interest Rate must be greater than zero."); } } }
//Calculate Interest public decimal CalcInterestRate() { return Balance * InterestRate; }
public override string ToString() { return "Account type: Savings -- Balance : " + Balance + "-- Interest Rate: " + InterestRate; } } }
Class Bank Please Choose An Account O Checking O Savings Initial Balance Deposit Withdraw See Balance Exit Interest Rate: 0.8% Final Total Transaction Fee: $1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
