Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this week\'s assignment you will be creating a Banking application. Create a

ID: 3600143 • Letter: F

Question

For this week's assignment you will be creating a Banking application. Create a console application that will:

Prompt the user for their fullname, account type to create ("C" -Checking vs. "S" -Savings) and their opening balance.

Take in an input from the user to either "D" -Deposit or "W" -Withdraw money from their specified account "C" -Checking or "S" -Savings.

Enforce the following business rules in your code:

Any time a deposit is made to the "S" -Savings account, the bank should match 5% of the deposit

Whenever a withdrawl causes the account balance to fall below $0, a penalty should be applied. The penalty for the "C" -Checking and "S" -Savings account is $20 and $30, respectively.

Display a message to the user when the balance in any of the account goes under $0. The message should state the account that is in negative.

Display the ending balances for both the accounts to the user after a transaction is completed.

In order to get full credit, you must do the following:

1. Introduce an abstract class Account.cs

2. Introduce 2 classes that inherit from the Account.cs class (SavingsAccount & CheckingAccount)

3. Have an abstract method MakeDeposit() in the Account.cs class

4. Implement the MakeDeposit() in the derived classes

5. Have an abstract method ApplyPenalty() in the Account.cs class

6. Implement the ApplyMethod() to deduct the penalty amount from the account balance

Explanation / Answer

// Hi, Here is the code:

//Accounts.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ClassLibrary1

{

public abstract class Account

{

public abstract void MakeDeposit(Double amount);

public abstract void ApplyPenalty();

}

}

//Savings.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ClassLibrary1

{

public class Savings : Account

{

private double savingsBalance = 0;

public Savings(Double amount)

{

this.savingsBalance = amount;

}

public override void MakeDeposit(Double amount)

{

Double conditionalAmount = savingsBalance * 5 / 100;

if (amount == conditionalAmount)

this.savingsBalance += amount;

else

Console.WriteLine("Please enter the amount which is 5% of the existing balance i.e. : {}", conditionalAmount);

}

public override void ApplyPenalty()

{

savingsBalance -= 30;

}

public void Withdraw(Double amount)

{

if (savingsBalance - amount < 0)

{

Console.WriteLine("Negative");

ApplyPenalty();

return;

}

savingsBalance -= amount;

}

public Double GetSavingsBalance()

{ return this.savingsBalance; }

}

}

//Checkings.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ClassLibrary1

{

public class Checkings : Account

{

private double checkingsBalance;

public Checkings(Double amount)

{

this.checkingsBalance = amount;

}

public override void MakeDeposit(Double amount)

{

this.checkingsBalance += amount;

}

public override void ApplyPenalty()

{

checkingsBalance -= 20;

}

public void Withdraw(Double amount)

{

if (checkingsBalance - amount < 0)

{

Console.WriteLine("Negative");

ApplyPenalty();

}

checkingsBalance -= amount;

}

public Double GetCheckingsBalance()

{ return this.checkingsBalance; }

}

}

//Banking.cs // Driver Class for testing

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ClassLibrary1

{

public class Banking

{

static void Main(string[] args)

{

Checkings checkingAccount = null;

Savings savingsAccount = null;

bool flag = true;

while (flag)

{

Console.WriteLine("Enter "C"-Checkings or "S"-Savings Account Opening ");

var input = Console.ReadKey();

if (input.ToString().Equals("C"))

{

Console.WriteLine("Enter Amount to deposit: ");

Double amount = Double.Parse(Console.ReadLine());

checkingAccount = new Checkings(amount);

flag = false;

}

else if (input.ToString().Equals("S"))

{

Console.WriteLine("Enter Amount to deposit: ");

Double amount = Double.Parse(Console.ReadLine());

savingsAccount = new Savings(amount);

flag = false;

}

else

{

Console.WriteLine("Invalid Selection!!Retry");

}

}

while (true)

{

Console.WriteLine("Enter "D"-Deposit or "W"-Withdraw");

var input = Console.ReadKey();

if (input.ToString().Equals("D"))

{

Console.WriteLine("Enter Amount to deposit: ");

Double amount = Double.Parse(Console.ReadLine());

if (checkingAccount != null)

{

checkingAccount.MakeDeposit(amount);

Console.WriteLine("Available balance in Checkings: " + checkingAccount.GetCheckingsBalance());

}

else if (savingsAccount != null)

{

savingsAccount.MakeDeposit(amount);

Console.WriteLine("Available balance in Savings: " + savingsAccount.GetSavingsBalance());

}

}

else if (input.ToString().Equals("W"))

{

Console.WriteLine("Enter Amount to Withdraw: ");

Double amount = Double.Parse(Console.ReadLine());

if (checkingAccount != null)

{

checkingAccount.Withdraw(amount);

Console.WriteLine("Available balance in Checkings: " + checkingAccount.GetCheckingsBalance());

}

else if (savingsAccount != null)

{

savingsAccount.Withdraw(amount);

Console.WriteLine("Available balance in Savings: " + savingsAccount.GetSavingsBalance());

}

}

else

{

Console.WriteLine("Invalid Selection!!Retry");

}

}

}

}

}

//Run the code and comment if you get any doubt. Happy Chegging.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote