Question

must be written in c# using windows application Scenario: Samediff bank has a 25-year old banking...

must be written in c# using windows application

Scenario: Samediff bank has a 25-year old banking account system. It was created using procedural programming. Samediff bank needs to improve the security and maintainability of the system using an object-oriented programming (OOP) approach. Their bank manager has decided to hire you to develop, implement, and test a new OOP application using efficient data structures and programming techniques.Samediff banks manager is excited to consider updating their account system. An expert has advised that they would be able to increase both security and ease of maintenance by using object oriented concepts such as polymorphism.

Create an inheritance hierarchy that a bank will use to represent customers’ bank accounts. All customers of Samediff bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. Each month they process interest earned and penalties on each account. Specific types of accounts exist. Each type of account you will need to consider in your inheritance hierarchy is listed below.You will need to create a list of accounts, in which you will have different types of accounts. account[] accountslist=new account[10];

account[0]=new savings();

account[1]=new checking();

or List accounts; accounts.add(new checking());

accounts.add(new savings());

You must complete these steps in your code

1. A menu system to add customers and accounts, delete customers and accounts.

2. Print customers with each customers accounts sorted by the last name of each customer.

3. Demonstrate that one customer can have more than one account.

4. Demonstrate a deposit and withdrawal of a customers account balance.

5. Demonstrate earned interest on an account.

6. Demonstrate penalties applied to an account.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Account.cs====

namespace BankWindowsApplication
{
public abstract class Account
{
public string AccountId { get; set; }

public decimal Balance { get; set; }

public decimal AccruedInterest { get; set; }

public decimal AccruedPenalties { get; set; }

public abstract decimal Withdraw(decimal amount);

public abstract decimal Deposit(decimal amount);

public abstract decimal CalculateInterest();

public abstract decimal CalculatePenalties();
}
}

CheckingAccount====

namespace BankWindowsApplication
{
public class CheckingAccount : Account
{
private const decimal processingFees = 1M;

public override decimal CalculateInterest()
{
this.AccruedInterest = 0;
if (this.Balance > 100M)
{
this.AccruedInterest = this.Balance * 0.02M - processingFees * 0.01M;
}

this.AccruedInterest = this.Balance * 0.01M;
return this.AccruedInterest;
}

public override decimal CalculatePenalties()
{
this.AccruedPenalties = 0;
if (this.Balance < 10M)
{
this.AccruedPenalties = this.Balance * 0.02M + processingFees * 0.01M;
}

return this.AccruedPenalties;
}
public override decimal Deposit(decimal amount)
{
this.Balance += amount - processingFees;
return this.Balance;
}

public override decimal Withdraw(decimal amount)
{
this.Balance -= amount - processingFees;
return this.Balance;
}
}
}

SavingAccount===

namespace BankWindowsApplication
{
public class SavingAccount : Account
{
public override decimal CalculateInterest()
{
this.AccruedInterest = 0;
if (this.Balance > 100M)
{
this.AccruedInterest = this.Balance * 0.02M;
}

this.AccruedInterest = this.Balance * 0.01M;
return this.AccruedInterest;
}

public override decimal CalculatePenalties()
{
this.AccruedPenalties = 0;
if (this.Balance < 10M)
{
this.AccruedPenalties = this.Balance * 0.02M;
}

return this.AccruedPenalties;
}

public override decimal Deposit(decimal amount)
{
this.Balance += amount;
return Balance;
}

public override decimal Withdraw(decimal amount)
{
this.Balance -= amount;
return Balance;
}
}
}

Customer.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BankWindowsApplication
{
public class Customer
{
public string CustomerID { get; set; }

public string FirstName { get; set; }

public string LastName { get; set; }

public string Address { get; set; }

public List<string> CustomerAccounts{ get; set; }
}
}

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BankWindowsApplication
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

Form1.cs:==========================

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BankWindowsApplication
{
public partial class Form1 : Form
{
private Dictionary<string, Account> Accounts;

private Dictionary<string, Customer> Customers;
public Form1()
{
InitializeComponent();
Accounts = new Dictionary<string, Account>();
Customers = new Dictionary<string, Customer>();
}

private void addAccountMenuItem_Click(object sender, EventArgs e)
{
HideAll();
txtAddAccountId.Clear();
cmbAccountType.Text = string.Empty;
txtAddAccountCustomerId.Clear();
grpbxAddAccount.Show();
grpbxAddAccount.Location = new Point(44,38);
txtAddAccountId.Focus();
}

private void btnAddCustomer_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txtAddCustomerId.Text))
{
MessageBox.Show("Please add customer id");
return;
}
if (Customers.ContainsKey(txtAddCustomerId.Text))
{
MessageBox.Show("Customer Already exists");
return;
}
Customer customer = new Customer();
customer.CustomerID = txtAddCustomerId.Text;
customer.FirstName = txtAddCustomerFirstName.Text;
customer.LastName = txtAddCustomerLastName.Text;
customer.Address = txtAddCustomerAddress.Text;
customer.CustomerAccounts = new List<String>();
Customers.Add(txtAddCustomerId.Text, customer);
MessageBox.Show("Customer added successfully");
grpbxAddCustomer.Hide();
}

private void btnCancelAddCustomer_Click(object sender, EventArgs e)
{
grpbxAddCustomer.Hide();
}

private void addCustomerMenuItem_Click(object sender, EventArgs e)
{
HideAll();
  
txtAddCustomerId.Clear();
txtAddCustomerFirstName.Clear();
txtAddCustomerLastName.Clear();
txtAddCustomerAddress.Clear();
grpbxAddCustomer.Show();
grpbxAddCustomer.Location = new Point(44, 38);
txtAddCustomerId.Focus();
}

private void deleteCustomerMenuItem_Click(object sender, EventArgs e)
{
HideAll();
txtDeleteCustomerId.Clear();
grpbxDeleteCustomer.Show();
grpbxDeleteCustomer.Location = new Point(44, 38);
txtDeleteCustomerId.Focus();
}

private void btnOkDeleteCustomer_Click(object sender, EventArgs e)
{
if (!Customers.ContainsKey(txtDeleteCustomerId.Text))
{
MessageBox.Show("Customer does not exist");
return;
}

Customers.Remove(txtDeleteCustomerId.Text);
MessageBox.Show("Customer deleted successfully");
grpbxDeleteCustomer.Hide();
}

private void btnCancelDeleteCustomer_Click(object sender, EventArgs e)
{
grpbxDeleteCustomer.Hide();
}

private void btnOkAddAccount_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txtAddAccountId.Text))
{
MessageBox.Show("Enter Account Id");
return;
}
  
if (Accounts.ContainsKey(txtAddAccountId.Text))
{
MessageBox.Show("Account Already exists");
return;
}

if (!Customers.ContainsKey(txtAddAccountCustomerId.Text))
{
MessageBox.Show("Customer does not exist");
return;
}

Account account = null;
if (cmbAccountType.Text == "Saving")
{
account = new SavingAccount();
}
else
account = new CheckingAccount();

account.AccountId = txtAddAccountId.Text;
account.Balance = 100M; //initial balance
Accounts.Add(txtAddAccountId.Text, account);
Customers[txtAddAccountCustomerId.Text].CustomerAccounts.Add(txtAddAccountId.Text);
MessageBox.Show("Customer added successfully");
grpbxAddAccount.Hide();
}

private void btnCancelAddAccount_Click(object sender, EventArgs e)
{
grpbxAddAccount.Hide();
}

private void btnOkDeleteAccount_Click(object sender, EventArgs e)
{
if (!Accounts.ContainsKey(txtDeleteAccountId.Text))
{
MessageBox.Show("Account does not exist");
return;
}

var customer = Customers.Where(x => x.Value.CustomerAccounts.Contains(txtDeleteAccountId.Text)).FirstOrDefault();
if (customer.Value !=null)
{
customer.Value.CustomerAccounts.Remove(txtDeleteAccountId.Text);
}
Accounts.Remove(txtDeleteAccountId.Text);
MessageBox.Show("Account deleted successfully");
grpbxDeleteAccount.Hide();
}

private void btnCancelDeleteAccount_Click(object sender, EventArgs e)
{
grpbxDeleteAccount.Hide();
}

private void deleteAccountMenuItem_Click(object sender, EventArgs e)
{
HideAll();
txtDeleteAccountId.Clear();
grpbxDeleteAccount.Show();
grpbxDeleteAccount.Location = new Point(44, 38);
txtDeleteAccountId.Focus();
}

  


private void showTransactionScreenToolStripMenuItem_Click(object sender, EventArgs e)
{
HideAll();
txtShowTransactionCustomerId.Clear();
cmbShowTransactionAccounts.Text = "";
grpbxShowTransaction.Show();
grpbxShowTransaction.Show();
grpbxShowTransaction.Location = new Point(44, 38);
txtShowTransactionCustomerId.Focus();
}

private void btnCancelShowTransaction_Click(object sender, EventArgs e)
{
grpbxShowTransaction.Hide();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void HideAll()
{
grpbxAddAccount.Hide();
grpbxAddCustomer.Hide();
grpbxDeleteAccount.Hide();
grpbxDeleteCustomer.Hide();
grpbxShowTransaction.Hide();
}

private void btnShowBalance_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txtShowTransactionCustomerId.Text) || string.IsNullOrWhiteSpace(cmbShowTransactionAccounts.Text))
{
MessageBox.Show("Select Account ID or Customer ID");
return;
}

if (!Accounts.ContainsKey(cmbShowTransactionAccounts.Text))
{
MessageBox.Show("Account does not exist");
return;
}

MessageBox.Show("Balance is" + Accounts[cmbShowTransactionAccounts.Text].Balance);
}

private void btnShowInterest_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txtShowTransactionCustomerId.Text) || string.IsNullOrWhiteSpace(cmbShowTransactionAccounts.Text))
{
MessageBox.Show("Select Account ID or Customer ID");
return;
}

if (!Accounts.ContainsKey(cmbShowTransactionAccounts.Text))
{
MessageBox.Show("Account does not exist");
return;
}

MessageBox.Show("Interest is" + Accounts[cmbShowTransactionAccounts.Text].CalculateInterest());
}

private void btnPenalties_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txtShowTransactionCustomerId.Text) || string.IsNullOrWhiteSpace(cmbShowTransactionAccounts.Text))
{
MessageBox.Show("Select Account ID or Customer ID");
return;
}

if (!Accounts.ContainsKey(cmbShowTransactionAccounts.Text))
{
MessageBox.Show("Account does not exist");
return;
}

MessageBox.Show("Penalties is" + Accounts[cmbShowTransactionAccounts.Text].CalculatePenalties());
}

private void btnDeposit_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txtShowTransactionCustomerId.Text) || string.IsNullOrWhiteSpace(cmbShowTransactionAccounts.Text))
{
MessageBox.Show("Select Account ID or Customer ID");
return;
}

if (!Accounts.ContainsKey(cmbShowTransactionAccounts.Text))
{
MessageBox.Show("Account does not exist");
return;
}

Accounts[cmbShowTransactionAccounts.Text].Deposit(100M);
MessageBox.Show("Balance is" + Accounts[cmbShowTransactionAccounts.Text].Balance);
}

private void btnWithdraw_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txtShowTransactionCustomerId.Text) || string.IsNullOrWhiteSpace(cmbShowTransactionAccounts.Text))
{
MessageBox.Show("Select Account ID or Customer ID");
txtShowTransactionCustomerId.Focus();
return;
}

if (!Accounts.ContainsKey(cmbShowTransactionAccounts.Text))
{
MessageBox.Show("Account does not exist");
return;
}

Accounts[cmbShowTransactionAccounts.Text].Withdraw(100M);
MessageBox.Show("Balance is" + Accounts[cmbShowTransactionAccounts.Text].Balance);
}

private void CmbShowTransactionAccounts_GotFocus(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txtShowTransactionCustomerId.Text))
{
MessageBox.Show("Please enter Customer Id");
return;

}

if (!Customers.ContainsKey(txtShowTransactionCustomerId.Text))
{
MessageBox.Show("Account does not exist");
return;
}
var customer = Customers[txtShowTransactionCustomerId.Text];
if (customer.CustomerAccounts != null)
{
cmbShowTransactionAccounts.Items.Clear();
foreach (var item in customer.CustomerAccounts)
{
cmbShowTransactionAccounts.Items.Add(item);
}

}
  
}

private void btnPrintCustomer_Click(object sender, EventArgs e)
{
if (Customers.Count == 0)
{
MessageBox.Show("Please Add some costomer first");
return;

}
StringBuilder sb = new StringBuilder();
foreach (var customeritem in Customers.OrderBy(x=>x.Value.LastName))
{
sb.AppendLine("For Customer Last Name" + customeritem.Value.LastName);
foreach (var item in customeritem.Value.CustomerAccounts)
{
sb.AppendLine("Account " + item);
}
}

MessageBox.Show(sb.ToString());
}
}
}

Form1.Designer.cs:========================

Not allowed to update designer.cs due to char limitation.

Please rate your answer.

Thanks

Add a comment
Know the answer?
Add Answer to:
must be written in c# using windows application Scenario: Samediff bank has a 25-year old banking...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Samediff banks manager is excited to consider updating their account system. An expert has advised that...

    Samediff banks manager is excited to consider updating their account system. An expert has advised that they would be able to increase both security and ease of maintenance by using object oriented concepts such as polymorphism. Create an inheritance hierarchy that a bank will use to represent customers’ bank accounts. All customers of Samediff bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. Each month they process interest earned and penalties on...

  • Java project: A Bank Transaction System For A Regional Bank User Story A regional rural bank...

    Java project: A Bank Transaction System For A Regional Bank User Story A regional rural bank CEO wants to modernize banking experience for his customers by providing a computer solution for them to post the bank transactions in their savings and checking accounts from the comfort of their home. He has a vision of a system, which begins by displaying the starting balances for checking and savings account for a customer. The application first prompts the user to enter the...

  • C++ Design and implement a hierarchy inheritance system of banking, which includes Savings and Checking accounts...

    C++ Design and implement a hierarchy inheritance system of banking, which includes Savings and Checking accounts of a customer. Inheritance and virtual functions must be used and applied, otherwise, there is no credit. The following features must be incorporated: 1. The account must have an ID and customer’s full name and his/her social security number. 2. General types of banking transactions for both accounts, Checking and Savings: withdraw, deposit, calculate interest (based on the current balance, and if it was...

  • Create an Inheritance hierarchy that a bank may use to represent customer's bank accounts (Checking and...

    Create an Inheritance hierarchy that a bank may use to represent customer's bank accounts (Checking and Savings), this includes a GUI user interface that allows user to login, and deposit or withdraw, and application to display the transaction and final balance. All the bank customers can: - Create a new account - Deposit (Credit) money into their account and/or withdraw (debit) money from their account. - Application should expect user to login to their account using login/password Create necessary classes...

  • Textbook help its not in textbook solutions from the textbook C++ Programming 7th edition Malik,D.S Chapter...

    Textbook help its not in textbook solutions from the textbook C++ Programming 7th edition Malik,D.S Chapter 12 programming exercise 5 Banks offer various types of accounts, such as savings, checking, certificateof deposits, and money market, to attract customers as well as meet their specific needs. Two of the most commonly used accounts are savings andchecking. Each of these accounts has various options. For example, you mayhave a savings account that requires no minimum balance but has a lower interest rate....

  • You are to write a banking application in c# that keeps track of bank accounts. It will consist of three classes, Account, Bank and BankTest. The Account class is used to represent a savings account i...

    You are to write a banking application in c# that keeps track of bank accounts. It will consist of three classes, Account, Bank and BankTest. The Account class is used to represent a savings account in a bank. The class must have the following instance variables: a String called accountID                       a String called accountName a two-dimensional integer array called deposits (each row represents deposits made in a week). At this point it should not be given any initial value. Each...

  • Should be in C# Create an inheritance hierarchy that a bank might use to represent customers’...

    Should be in C# Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this back can deposit (i.e. credit) money into their accounts and withdraw (i.e. debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction. Create base class Account and derived classes SavingsAccount and CheckingAccount that inherit...

  • In C++ Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e.,...

    In C++ Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction (i.e., credit or debit). Create an inheritance hierarchy containing base class Account and derived...

  • c++ help please. Savings accounts: Suppose that the bank offers two types of savings accounts: one...

    c++ help please. Savings accounts: Suppose that the bank offers two types of savings accounts: one that has no minimum balance and a lower interest rate and another that requires a minimum balance but has a higher interest rate (the benefit here being larger growth in this type of account). Checking accounts: Suppose that the bank offers three types of checking accounts: one with a monthly service charge, limited check writing, no minimum balance, and no interest; another with no...

  • (C++) How do I develop a polymorphic banking program using an already existing Bank-Account hierarchy? For each account...

    (C++) How do I develop a polymorphic banking program using an already existing Bank-Account hierarchy? For each account in the vector, allow the user to specify an amount of money to withdraw from the Bank-Account using member function debit and an amount of money to deposit into the Bank-Account using member function credit. As you process each Bank-Account, determine its type. If a Bank-Account is a Savings, calculate the amount of interest owed to the Bank-Account using member function calculateInterest,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT