Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C#: I need to create instances of the these prompts with the following code: ### Prompt 1 - Instantiate a Bank Write a code snippet
C#: I need to create instances of the these prompts with the following code: ### Prompt Instantiate a Bank
Write a code snippet to create an instance of a Bank with a specified name and maximum number of accounts.
### Prompt Create Bank Accounts
Instantiate several BankAccount objects with different account numbers and associate them with the bank instance created in prompt
### Prompt Deposit Money
Write a method to deposit a certain amount of money into one of the BankAccount instances.
### Prompt Withdraw Money
Implement a code snippet to withdraw an amount from a BankAccount Check if the withdrawal is successful.
### Prompt Check Account Balance
Display the balance of a specific BankAccount after performing deposit and withdrawal operations.
### Prompt Handle Insufficient Funds
Attempt a withdrawal that exceeds the account balance and handle the that is returned by displaying an appropriate message.
### Prompt List All Accounts in a Bank
Loop through all accounts in a bank and display their details account number and balance
### Prompt Transfer Funds Between Accounts
Transfer funds from one account to another within the same bank.
### Prompt Bank Capacity Check Try adding more BankAccount instances to the bank than its maximum capacity allows and handle the error gracefully. public class Bank
public string Name get; set;
public BankAccount AccountList get; set;
public int NextOpenIndex get; set;
public Bankstring bankName, int maxNumAccounts
Name bankName;
AccountList new BankAccountmaxNumAccounts;
NextOpenIndex ;
public Bankstring bankName, BankAccount bankAccounts
Name bankName;
AccountList bankAccounts;
NextOpenIndex bankAccounts.Length;
public bool AddAccountBankAccount account
if NextOpenIndex AccountList.Length && AccountList.Containsaccount
AccountListNextOpenIndex account;
NextOpenIndex;
return true;
else
Console.WriteLineCannot add account. Either the bank is full or the account already exists.";
return false;
public bool TransferBankAccount accTransferFrom, BankAccount accTransferTo, double amount
if accTransferFromBalance amount
accTransferFrom.Withdrawamount;
accTransferTo.Depositamount;
return true;
else
Console.WriteLineThere are insufficient funds in account.";
return false;
public class BankAccount
public string AccountNumber get; set;
public double Balance get; set;
public BankAccountstring accountNumber, double initialBalance
AccountNumber accountNumber;
Balance initialBalance;
public void Depositdouble amount
Balance amount;
public bool Withdrawdouble amount
if Balance amount
Balance amount;
return true;
else
Console.WriteLineInsufficient funds.";
return false;
public double CheckBalance
return Balance;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started