using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assignment5
{
class Program
{
class BankAccount
{
private double balance;
public BankAccount() { balance = 0.0; }
public BankAccount(double iA)
{
balance = iA;
}
public virtual double Withdraw(double a)
{
if (balance >= a)
{
balance -= a;
return balance;
}
else
return -1.0;
}
public void Deposit(double a)
{
balance += a;
}
public double GetBalance() { return balance; }
public class CheckingAccount : BankAccount
{
private double minBalance, charge;
public CheckingAccount(double minA, double charge) : base()
{
minBalance = minA;
this.charge = charge;
}
public double ProcessCheck(double a)
{
double r;
if (GetBalance() >= minBalance)
r = base.Withdraw(a);
else
r = base.Withdraw(a + charge);
return 0.0;
}
public override double Withdraw(double a)
{
return ProcessCheck(a);
}
}
double x, y;
public class SavingsAccount : BankAccount
{
private double ir;
public SavingsAccount(double a, double r) : base(a)
{
ir = r;
}
public void PostInterest()
{
double balance = GetBalance();
double interest = balance * ir / 100;
Deposit(interest);
}
}
static void Main(string[] args)
{
CheckingAccount ca = new CheckingAccount(2000.0, 2.0);
Console.WriteLine("The initial balance is {0:c}", ca.GetBalance());
ca.Deposit(1000.0);
Console.WriteLine("Current balance after the deposit is {0:c}", ca.GetBalance());
ca.ProcessCheck(300.0);
Console.WriteLine("The balance after ProcessCheck is {0:c}", ca.GetBalance());
ca.Withdraw(500.0);
Console.WriteLine("The balance after withdrawl is {0:c}", ca.GetBalance());
CheckingAccount x = new CheckingAccount(2000.0, 2.0);
Console.WriteLine("The balance of x is {0:c}", x.GetBalance());
x.Deposit(1000.0);
Console.WriteLine("The balance after deposit is {0:c}", x.GetBalance());
x.Withdraw(500.0);
Console.WriteLine("The balance after withdrawl is {0:c}", x.GetBalance());
SavingsAccount y = new SavingsAccount(4000.0, 5.0);
Console.WriteLine("The balance of y is {0:c}", y.GetBalance());
y.Deposit(1000.0);
Console.WriteLine("The balance after the deposit is {0:c}", y.GetBalance());
y.Withdraw(500.0);
Console.WriteLine("The balance after withdrawl is {0:c}", y.GetBalance());
}
}
}
}
What I have tried:
I've tried and completed everything. The only problem I'm facing in the main for "CheckingAccount ca" and "CheckingAccount x", it's not showing my initial balance of 2000.0, 2.0 when I run the program. Can you help?
The assignment is below.
using System;
namespace A5a_YourLastName
{
public class BankAccount {…}
public class ChecingAccount {…}
public class QuizEx10_7
{
public static void Main()
{
}
}
}
Write the output from the above Main method:
using System;
namespace A5b_YourLastName
{
public class BankAccount {…}
public class SavingsAccount {…}
public class ChecingAccount {…}
public class QuizEx10_11
{
public static void Main()
{