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

Need help with the C# program below BankAccount -static nextAccountNumber : int

ID: 3558486 • Letter: N

Question

Need help with the C# program below

BankAccount

-static nextAccountNumber : int = 1000

-accountNumber : int

-balance : double = INITIAL_BALANCE

-INITIAL_BALANCE : double = 100

+BankAccount()

+BankAccount(in balance : double)

+ToString() : string

+CalcAvgDailyBalance() : double

+Deposit(in depAmount : double)

+Withdraw(in wdAmount : double)

Create a class BankAccount with the private attributes and public methods listed above. Also include properties for nextAccountNumber( get only), accountNumber and balance.

In the constructors, take the nextAccountNumber and put that value into accountNumber then add one to nextAccountNumber. In the default constructor, set the balance equal to the INITIAL_BALANCE.

The ToString should show the accountNumber and balance.

Deposit should add the depAmount to balance. Withdraw should subtract the wdAmount from balance.

CalcAvgDailyBalance should take the balance and divide by 365.

Use the Program class to test your BankAccount class. Create 2 instances of BankAccount, 1 with the default constructor and 1 with the overloaded constructor. Make at least 1 deposit and 1 withdraw from each account. Call ToString for both objects. Display the number of accounts.

BankAccount

-static nextAccountNumber : int = 1000

-accountNumber : int

-balance : double = INITIAL_BALANCE

-INITIAL_BALANCE : double = 100

+BankAccount()

+BankAccount(in balance : double)

+ToString() : string

+CalcAvgDailyBalance() : double

+Deposit(in depAmount : double)

+Withdraw(in wdAmount : double)

Explanation / Answer

Hi, I have been programming since 5 years and I work at microsoft. The default language we use there is C#. So, this code perfectly works. Pls vote as best answer. Thank you. Have a nice day :).

here;s the code without comments

using System.IO;
using System;

class BankAccount
{
public static int nextAccountNumber {get; private set; }
public int accountNumber {get;private set;}
private static double INITIAL_BALANCE = 100;
public double balance {get; private set;}
  
static BankAccount()
{
nextAccountNumber = 100;
  
}
  
public BankAccount()
{
this.accountNumber = nextAccountNumber;
nextAccountNumber +=1;
this.balance = INITIAL_BALANCE;
}
  
public BankAccount(int newBalance)
{
this.accountNumber = nextAccountNumber;
nextAccountNumber +=1;
this.balance = newBalance;
}
  
public override String ToString()
{
return ("The balance in the Account number " + this.accountNumber.ToString() + " is : " + this.balance.ToString());
}
  
public void Deposit(double depAmount)
{
this.balance +=depAmount;
}
  
public void Withdraw(double wdAmount)
{
this.balance -= wdAmount;
}

public double CalcAverageDailyBalance()
{
   return this.balance/365.0;

}


}
class Program
{
static void Main()
{
BankAccount b1 = new BankAccount();
Console.WriteLine(b1.ToString());
b1.Deposit(300);
Console.WriteLine("Deposited Rs.300");
Console.WriteLine(b1.ToString());
  
BankAccount b2 = new BankAccount(500);
Console.WriteLine(" " +b2.ToString());
b2.Withdraw(300);
Console.WriteLine("Withdrawn Rs.300");
Console.WriteLine(b2.ToString());
}
}

This is the code with comments.... and explanation.

using System.IO;
using System;

class BankAccount
{
public static int nextAccountNumber {get; private set; }
public int accountNumber {get;private set;}
private static double INITIAL_BALANCE = 100;
public double balance {get; private set;}
  
static BankAccount()
{

// setting the static integet to 100.
nextAccountNumber = 100;
}
  
// setting the account number and the initial balance as 100
public BankAccount()
{
this.accountNumber = nextAccountNumber;
nextAccountNumber +=1;
this.balance = INITIAL_BALANCE;
}

// if an argument is given, setting the balance to given one.
public BankAccount(int newBalance)
{
this.accountNumber = nextAccountNumber;
nextAccountNumber +=1;
this.balance = newBalance;
}
  


public override String ToString()
{
return ("The balance in the Account number " + this.accountNumber.ToString() + " is : " + this.balance.ToString());
}

// deposits amount to account
public void Deposit(double depAmount)
{
this.balance +=depAmount;
}
  

// withdraws amount from account
public void Withdraw(double wdAmount)
{
this.balance -= wdAmount;
}
  

public double CalcAverageDailyBalance()
{
   return this.balance/365.0;

}


}
class Program
{
static void Main()
{

// checking done here...
BankAccount b1 = new BankAccount();
Console.WriteLine(b1.ToString());
b1.Deposit(300);
Console.WriteLine("Deposited Rs.300");
Console.WriteLine(b1.ToString());
  
BankAccount b2 = new BankAccount(500);
Console.WriteLine(" " +b2.ToString());
b2.Withdraw(300);
Console.WriteLine("Withdrawn Rs.300");
Console.WriteLine(b2.ToString());
}
}

using System.IO;
using System;

class BankAccount
{
public static int nextAccountNumber {get; private set; }
public int accountNumber {get;private set;}
private static double INITIAL_BALANCE = 100;
public double balance {get; private set;}
  
static BankAccount()
{
nextAccountNumber = 100;
  
}
  
public BankAccount()
{
this.accountNumber = nextAccountNumber;
nextAccountNumber +=1;
this.balance = INITIAL_BALANCE;
}
  
public BankAccount(int newBalance)
{
this.accountNumber = nextAccountNumber;
nextAccountNumber +=1;
this.balance = newBalance;
}
  
public override String ToString()
{
return ("The balance in the Account number " + this.accountNumber.ToString() + " is : " + this.balance.ToString());
}
  
public void Deposit(double depAmount)
{
this.balance +=depAmount;
}
  
public void Withdraw(double wdAmount)
{
this.balance -= wdAmount;
}

public double CalcAverageDailyBalance()
{
   return this.balance/365.0;

}


}
class Program
{
static void Main()
{
BankAccount b1 = new BankAccount();
Console.WriteLine(b1.ToString());
b1.Deposit(300);
Console.WriteLine("Deposited Rs.300");
Console.WriteLine(b1.ToString());
  
BankAccount b2 = new BankAccount(500);
Console.WriteLine(" " +b2.ToString());
b2.Withdraw(300);
Console.WriteLine("Withdrawn Rs.300");
Console.WriteLine(b2.ToString());
}
}

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