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

Must be in c#: You will be creating a custom class that for a bank account. It w

ID: 3717954 • Letter: M

Question

Must be in c#:

You will be creating a custom class that for a bank account. It will track the user’s name, bank account and checking account. The user will make 3 deposits or withdrawals in either of the 2 accounts and the totals will be given.

1. First create a new custom class file called BankAccount.

2. Create your 3 member variables and the constructor function to build the object.

3. Create Getters and Setters for each of the 3 member variables

4. Code a custom method in the class file that will add the checking and banking account together and return the grand total.

5. In your Main Method:

a. Prompt the user for each of these variables and validate correctly. i. Full Name ii. Starting Checking Account Value iii. Starting Bank Account Value

b. Use these user prompted values to instantiate a new BankAccount object.

c. Once the object is created: i. Alert the user that it has been done and give them the starting values of each account. ii. Use the custom method and give the user the grand total of both of their accounts combined.

d. Next create a loop that will repeat for 3 times.

e. In the loop do the following for each iteration: i. Prompt the user if they would to withdrawal or deposit money.

1. You can have the user type in (1) for withdrawal or (2) for deposit. ii. Prompt the user for which account they would like to make the change to. iii. Using the getters and setters make the change, IF ALLOWED.

1. What this means is verify the user has enough funds if they are withdrawing money.

2. Example: do not let them take $1,000, if they only have $500. iv. At the end of each loop give the user their current total in each of their 2 accounts.

f. After the loop runs 3 times and changes have been made to the account balances: i. Give the user a final output with each account total. ii. Use the custom method and give the user the grand total of both of their accounts combined. • User Input (Ask & Validate In Main Method, Use To Instantiate Object as the Member Variables): o User’s Full Name o Starting Checking Account Value o Staring Bank Account Value • Constructor Function: o Take in all member variables and create an object from them • Custom Function o This function should take the checking member variable and add it to the banking account member variable to give the sum of both accounts.

Explanation / Answer

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

namespace ConsoleApplication1
{
class BankAccount
{
//Create member variable with getter setter
public string User_Name { get; set; }
public decimal Bank_Account { get; set; }
public decimal Checking_Account { get; set; }
//constructor
BankAccount()
{
  
this.User_Name = "";
this.Checking_Account = 0;
this.Bank_Account = 0;

}

static void Main(string[] args)
{
string full_name, status;
decimal Bank_Account_Value = 0, Checking_Account_value = 0;
//Enter Full name, Starting Checking Account value, Starting Bank Account Value
Console.WriteLine("Enter Full Name : ");
full_name = Convert.ToString(Console.ReadLine());
Console.WriteLine("Enter Starting Checking Account Value : ");
Checking_Account_value = Convert.ToDecimal(Console.ReadLine());
Console.WriteLine("Enter Starting Bank Account Value : ");
Bank_Account_Value = Convert.ToDecimal(Console.ReadLine());
// Create class object and enter value
BankAccount ba = new BankAccount();
ba.Bank_Account = Bank_Account_Value;
ba.Checking_Account = Checking_Account_value;
ba.User_Name = full_name;

Console.Write(" the grand total of both of their accounts combined : " + Convert.ToString(addbankaccount(Bank_Account_Value, Checking_Account_value)));
// loop for 3 times
for (int i = 0; i < 3; i++)
{
Console.Write(" =================================================================================================");
//select withdrawl or deposite
Console.WriteLine(" if you would to withdrawal money then press 'W' or deposit money then press 'D' : ");
status = Convert.ToString(Console.ReadLine());
if (status == "W")
{
string acc;
//Select one account from 2 account value
Console.WriteLine(" if you would to withdrawal money from bank account then press 'B' or for checking account then press 'C' : ");
acc = Convert.ToString(Console.ReadLine());
decimal withdraw;

if (acc == "B")
{
//Enter withdrawal money
Console.WriteLine(" Enter withdrawal money :");
withdraw = Convert.ToDecimal(Console.ReadLine());
//check withdrawal money with Account
if (withdraw > ba.Bank_Account)
{
Console.Write(" current total balance in Bank account is :" + ba.Bank_Account + " and Checking account is :" + ba.Checking_Account);
}
else
{
ba.Bank_Account = ba.Bank_Account - withdraw;
Console.Write(" Available balance in Bank account is :" + ba.Bank_Account);
}
}
else if (acc == "C")
{
//Enter withdrawal money
Console.WriteLine(" Enter withdrawal money :");
withdraw = Convert.ToDecimal(Console.ReadLine());
//check withdrawal money with Account
if (withdraw > ba.Checking_Account)
{
Console.Write(" current total balance in Bank account is :" + ba.Bank_Account + " and Checking account is :" + ba.Checking_Account);
}
else
{
ba.Checking_Account = ba.Checking_Account - withdraw;
Console.Write(" Available balance in checking account is :" + ba.Checking_Account);
}
}
  
}
else if (status == "D")
{
string acc;
//select withdrawl or deposite
Console.WriteLine(" if you would to withdrawal money from bank account then press 'B' or for checking account then press 'C' : ");
acc = Convert.ToString(Console.ReadLine());
decimal deposite;

if (acc == "B")
{
//Enter deposite money
Console.WriteLine(" Enter deposite money :");
deposite = Convert.ToDecimal(Console.ReadLine());
ba.Bank_Account = ba.Bank_Account + deposite;
Console.Write(" Available balance in Bank account is :" + ba.Bank_Account);
}
else if (acc == "C")
{
//Enter deposite money
Console.WriteLine(" Enter deposite money :");
deposite = Convert.ToDecimal(Console.ReadLine());
ba.Checking_Account = ba.Checking_Account + deposite;
Console.Write(" Available balance in checking account is :" + ba.Checking_Account);
}
  
}
Console.Write(" =================================================================================================");
}
//show grand total
Console.Write(" Grand Total of both account :" + Convert.ToString(addbankaccount(ba.Bank_Account, ba.Checking_Account)));
Console.ReadLine();

}
static decimal addbankaccount(decimal Bank_Account_Value, decimal Checking_Account_value)
{
return Bank_Account_Value + Checking_Account_value;
}
}

}