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

Write an application that creates different bank accounts. You have to design an

ID: 3910720 • Letter: W

Question

Write an application that creates different bank accounts. You have to design an object-oriented solution using two classes. “BankAccount” class: Variables (Attributes): a. first name b. last name c. yearly interest rate d. balance Functions (Methods): 1. default constructor 2. constructor with one parameter (yearly interest rate) 3. properties “BankAccountTest” class: instantiate two objects of the “BankAccount” class, checking and saving accounts and use the constructor to initialize the yearly interest rate for each account (0.5% for checking account, 2.3% for saving account). Allow the user to input his/her name and the balances for both accounts. After the user inputs all the data, the program displays user’s name and initial balances for both accounts. Then, the program calculates the balances with the interest after one year and updates the balances for both accounts (objects) and displays the new balances for both accounts. Repeat the step for two years of balance and display the new balance after two years for both accounts.

*2017 visuol studo C# console

Explanation / Answer

using System;

namespace bank
{
public class BankAccount
{
public String Fname{ get; set; }
public String Lname { get; set; }
public double yearly_ir { get; set; }
public double bal { get; set; }

public BankAccount()
{
yearly_ir = 0;
bal = 0;
Fname = "";
Lname = "";
}

public BankAccount(double interest)
{
yearly_ir = interest;
bal = 0;
Fname = "";
Lname = "";

}

public void getData() {
Console.WriteLine(" Name: " + Fname + " " + Lname);
Console.WriteLine("Balance: " + bal+" ");
}
}

class BankAccountTest
{
static void Main(string[] args)
{
String fn, ln;
double bal;
BankAccount checking = new BankAccount(0.5);

BankAccount saving = new BankAccount(2.3);

Console.WriteLine("Details of checking account holder");
Console.WriteLine("Enter first name");
fn = Console.ReadLine();
Console.WriteLine("Enter last name");
ln = Console.ReadLine();
Console.WriteLine("Enter balance");
bal =Convert.ToDouble( Console.ReadLine());
checking.Fname = fn;
checking.Lname = ln;
checking.bal = bal;
Console.WriteLine(" Details of saving account holder");
Console.WriteLine("Enter first name");
fn = Console.ReadLine();
Console.WriteLine("Enter last name");
ln = Console.ReadLine();
Console.WriteLine("Enter balance");
bal = Convert.ToDouble(Console.ReadLine());
saving.Fname = fn;
saving.Lname = ln;
saving.bal = bal;
checking.getData();
saving.getData();
checking.bal += (checking.yearly_ir * bal)/100;
saving.bal += (saving.yearly_ir * bal)/100;
Console.WriteLine("Balances after One year: ");
checking.getData();
saving.getData();
checking.bal += (checking.yearly_ir * bal) / 100;
saving.bal += (saving.yearly_ir * bal) / 100;
Console.WriteLine("Balances after Two years: ");
checking.getData();
saving.getData();
checking.bal += (checking.yearly_ir * bal) / 100;
saving.bal += (saving.yearly_ir * bal) / 100;
Console.WriteLine("Balances after Three year: ");
checking.getData();
saving.getData();


}

}
}

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