CSIS 209 Programming Assignment 4



Create a class called SavingsAccount. Use a static variable called annualInterestRate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12 – this interest should be added to savingsBalance. Provide static method setAnnualInterestRate to set the annualInterestRate to a new value.
Write an application to test class SavingsAccount. Create three savingsAccount objects, saver1, saver2, and saver3 with balances of $2,000.00, $3,000.00, and 0.00, respectively. Set annualInterestRate to 4%, then calculate the monthly interest and display the new balances for both savers. Then set the annualInterestRate to 5%, calculate the next month’s interest and display the new balances for both savers.
Technical Requirements:
Create SavingsAccount class with static variable annualInterestRate and private instance variables savingsBalance (double) and savingsAccountName (string).
Create a mutator method to set the savingsAccountName. Call this method setSavingsAccountName. The method should take a string argument and return void.
Create an accessor method to retrieve the savingsAccountName. Call this method getSavingsAccountName. The method should take no arguments and return a string (i.e. the savingsAccountName).
Create a mutator method to set the savingsBalance. Call this method setSavingsBalance. The method should take a double argument and return void.
Create an accessor method to retrieve the savingsBalance. Call this method getSavingsBalance. The method should take no arguments and return a double (i.e. the savingsBalance).
Include two constructors. The first takes no arguments and sets the savingsBalance variables to zero and sets the savingsAccountName to an empty string by calling the second (i.e. two argument) constructor with 0 and an empty string. The second constructor takes one double argument (the savingsBalance) and one string argument (the savingsAccountName), and sets the savingsBalance by calling the setSavingsBalance method and setsavingsAccountName method, respectively.
Create CalculateMonthlyInterest method with formula. The method should return void.
Create setAnnualInterestRate method to take a double argument representing the annualInterestRate and return void.
Create PrintSavingsAccount method to display the savingsBalance, savingsAccountName, and annualInterestRate for an object. Use the output shown below as a guideline for the display.
Create a separate class called SavingsAccountTest, which contains the Main() method.
In the Main() method, create three savingsAccount objects called saver1, saver2, and saver3. Initialize saver1 and saver2 with the balances listed above and the names “Saver_One” and “Saver_Two”, respectively. Do not initialize saver3 with anything. Instead, create the object by invoking its zero-argument constructor, which will initialize its balance to 0 and its name to an empty string.
In the Main() method, call setAnnualInterestRate to set the interest rate to 4%.
Next, call the setSavingsAccountName for saver3 to set its name to “Saver_Three”. Then, call the setSavingsAccountBalance for saver3 to set its balance to $50,000.
Print the results by calling PrintSavingsAccount for each object.
Next, call the CalculateAnnualInterestRate method for all three saver objects.
Print the results again by calling PrintSavingsAccount for each object.
Next, change the annualInterestRate to 5% by calling the setAnnualInterestRate method.
Print the results again by calling PrintSavingsAccount for each object.
The solution includes a Visual Studio (c#) project
Attachments [Move over files to preview content of those files] (111.22 KB)
Visual Studio project
Preview SavingsAccount.cs
xxxxxx xxxxxx xxxxxx xxxxxxxxxxxxxxxxxx;
xxxxxxx xxxxxx xxxxxxxxxxxxxx;
xxxxxxx xxxxxx xxxxxxxxxxxxxxxxxx;
xxxxxx xxxxxxxxxxxxxx()
public SavingsAccount(double balance, string accountName) { setSavingsAccountName(accountName); setSavingsBalance(balance); }
public void setSavingsAccountName(string accountName) {
xxxxxxxxxxxxxxxxxx = xxxxxxxxxxx;
xxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxx()
xxxxxx xxxxxxxxxxxxxxxxxx;
Preview SavingsAccountTest.cs
xxxxxx xxxx xxxx(xxxxxx[] xxxx)
xxxxxxxxxxxxxx xxxxx1 = xxx xxxxxxxxxxxxxx(2000.00, “xxxxx_xxx”);
xxxxxxxxxxxxxx xxxxx2 = xxx xxxxxxxxxxxxxx(3000.00, “xxxxx_xxx”);
xxxxxxxxxxxxxx xxxxx3 = xxx xxxxxxxxxxxxxx();
Console.WriteLine(“Initial savings account balance:”); SavingsAccount.setAnnualInterestRate(0.04); // set the interest rate to 4%. saver3.setSavingsAccountName(“Saver_Three”); saver3.setSavingsBalance(50000); Console.WriteLine(“{0,15}{1,15}{2,25}”, “Account Name”, “Balance”, “Annual Interest Rate”); // calling PrintSavingsAccount for each object saver1.PrintSavingsAccount(); saver2.PrintSavingsAccount(); saver3.PrintSavingsAccount(); Console.WriteLine();
// call the CalculateAnnualInterestRate method for all three saver objects
xxxxxxx.xxxxxxxxx(“xxxxxxx xxxxxxx xxxxxxx xxxxx xxxxxxxxxxx xxxxxxx xxxxxxxx xx 4%:”);
xxxxxxx.xxxxxxxxx(“{0,15}{1,15}{2,25}”, “xxxxxxx xxxx”, “xxxxxxx”, “xxxxxx xxxxxxxx xxxx”);
Price: $19
Buy Now
Added to cart
Buy More Save More
Buy at least TWO items & save up to 30% OFF your ENTIRE order!
Rack up instant rebates in your shopping cart. Simply add items to your cart, and see the savings add up.
Discounts will automatically be applied on eligible orders.
CSIS 209 Programming Assignment 4 – $19.00
CSIS 209 Programming Assignment 5 – $19.00
CSIS 209 Programming Assignment 6 – $19.00
CSIS 209 Programming Assignment 7 – $19.00
CSIS 209 Programming Assignment 8 – $25.00
Add to Cart
Added to cart
You May Also Like:
CSIS 209 Programming Assignment 1
CSIS 209 Programming Assignment 2
CSIS 209 Programming Assignment 3
CSIS 209 Programming Assignment 5
CSIS 209 Programming Assignment 6
CSIS 209 Programming Assignment 7
CSIS 209 Programming Assignment 8


There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.