logo CodeStepByStep logo

BankAccount

Language/Type: C# classes

Write a class of objects named BankAccount that remembers information about a user's account at a bank. You must include the following public members:

member name type description
new BankAccount(name) constructor constructs a new account for the person with the given name, with $0.00 balance
ba.Name property the account name as a string (read-only)
ba.Balance property the account balance as a real number (read-only)
ba.Deposit(amount); method adds the given amount of money, as a real number, to the account balance; if the amount is negative, does nothing
ba.Withdraw(amount); method subtracts the given amount of money, as a real number, from the account balance; if the amount is negative or exceeds the account's balance, does nothing

You should define the entire class including the class heading, the private instance variables, and the declarations and definitions of all the public member functions and constructor.

Class: Write a complete C# class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.