NEEDED IN C# use C# to write an application for handling saving accounts. Create
ID: 3695388 • Letter: N
Question
NEEDED IN C#
use C# to write an application for handling saving accounts. Create a class SavingAccount. Do the following with this class:
Create a publicly accessible static variable interestRate. Use type decimal. Initialize it to 0.02m.
Create two publicly accessible auto-implemented properties Name and Balance. They are used to store account’s name and balance.
Create a publicly accessible constructor that has one parameter. This parameter is used to initialize Name.
Create another publicly accessible constructor that has two parameters. The first parameter is used to initialize Name while the second parameter is used to initialize Balance.
Create a publicly accessible void method DisplayInfo with no parameter. This method displays Name, Balance and interestRate on computer screen.
Using the following code to test your SavingAccount class:
static void Main(string[] args)
{
SavingAccount acct1 = new SavingAccount("Peter Chen");
SavingAccount acct2 = new SavingAccount("Al Molin", 5000m);
acct1.DisplayInfo();
Console.WriteLine();
acct2.DisplayInfo();
Console.WriteLine();
Console.WriteLine("Changing interest rate to 3%");
SavingAccount.interestRate = 0.03m;
acct1.DisplayInfo();
Console.WriteLine();
acct2.DisplayInfo();
Console.WriteLine();
}
Explanation / Answer
1. Consider the following 'nonsense class'.
2. With the nonsense class from the preceding exercise, determine what the following program prints.
It prints 9 and 17 and here's why:
Supply a method compareTo that tests whether one address comes before another when the addresses are compared by postal code.
Enhance the Account class to compute interest on the current balance.
Here the account string is "S" or "C". For the deposit or withdrawal, it indicates which account is affected. For a transfer it indicates the account from which the money is taken; the money is automatically transferred to the other account.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.