Placeholder

CSIS 209 Programming Assignment 6

$19.00

Description

Develop a polymorphic banking application using the Account hierarchy you created in Assignment #5. Create the following two SavingsAccount objects and two CheckingAccount objects and store them in an array called “arrays” of Account references to the objects:
Account Name
Account Number
Initial Balance
Fee Charged
Interest Rate
Using a “foreach” loop, iterate over each account in the array. For each Account in the array, first print the account. Next, allow the user to specify an amount of money to withdraw from the Account using method Debit and an amount of money to deposit into the Account using method Credit. Specifically, for each account, prompt the user to enter an amount to deposit in the account and call the Credit method. Print the object. Next, prompt the user to enter an amount to withdraw and call the Debit method. Print the object. After the user has made a deposit and a withdrawal from an account, calculate interest if the account is a SavingsAccount and print the object. To perform this step, you must first determine the object’s type. If the Account is a SavingsAccount, calculate the amount of interest owed to the Account using method CalculateInterest and print the account a final time. If the account is a CheckingAccount, you do not need to CalculateInterest nor print the account a final time.
Hint: To determine if an account is a savings or checking account, use the .getType method which returns a string representing the Name or FullName property. Then use the “.Equals” method to determine if the returned string is equal to the name of the class.
For example:
acct.getType().Name returns the string “SavingsAccount” or “CheckingAccount”.
Once you have determined that an account is a SavingsAccount object, you must “cast” the account object into a SavingsAccount object in order to access its CalculateInterest method. I like to perform this in two steps: declare a different variable to hold the reference to the object that has been cast from an Account object into a SavingsAccount object. Then, using this new variable, invoke its CalculateInterest method. For example, at the beginning of the Main() method, I declare a variable of type SavingsAccount as follows:
SavingsAccount temp_account;
In my foreach loop, I have a variable called “acct” that is defined as an Account object. To downcast this Account object into a SavingsAccount object, I use the syntax:
temp_account = (SavingsAccount) acct;
At this point, because temp_account is a SavingsAccount object, I can invoke its
CalculateInterest method:
temp_account.CalculateInterest();
SCREENSHOTS
SOLUTION
PAYMENT
The solution includes a Visual Studio (c#) project
Attachments [Move over files to preview content of those files]
CSIS209_Programming_Assignment_6.zip (111.35 KB)
CSIS209-Programming-Assignment-6-Screenshot.png
Visual Studio project
CSIS209ProgrammingAssignment6
CSIS209ProgrammingAssignment6
Account.cs
App.config
bin
Debug
CSIS209ProgrammingAssignment6.vshost.exe
CSIS209ProgrammingAssignment6.vshost.exe.config
CSIS209ProgrammingAssignment6.vshost.exe.manifest
CheckingAccount.cs
CSIS209ProgrammingAssignment6.csproj
obj
Debug
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Program.cs
Properties
AssemblyInfo.cs
SavingsAccount.cs
CSIS209ProgrammingAssignment6.sln
CSIS209ProgrammingAssignment6.v12.suo
Preview Account.cs
xxxxxxx xxxxxx xxxxxxxxxxx { xxx; xxx; } // xxxxxxxxxx xxx xxxxxxx xxxxxx’x xxxx xxxx
xxxxxxx xxx xxxxxxxxxxxxx { xxx; xxx; } // xxxxxxxxxx xxx xxxxxxx’x xxxxxx
xxxxxxx xxxxxx xxxxxxx; // xxxxxxxxx xxx xxxxxxx xxxxxxx
public double Balance { get { return balance; } set { balance = value; } }
public string AccountName { get { return accountName; } set { accountName = value; } }
// xxxxxxx xxxxxxxxx
xxxxxx xxxxxxx()
{
}
// xxxxxxxxxxx xxxx xxxxxxxx xx xxxxxxx’x xxxx, xxxxxxx xxxxxx, xxx xx xxxxxxx xxxxxxx
Preview CheckingAccount.cs
xxxxxxx xxxxxx xxxxxxxxxx;
// xxxxxxx xxxxxxxxx
xxxxxx xxxxxxxxxxxxxxx()
{
}
public CheckingAccount(string accountName, int accountNumber, double initBalance, double feeCharged) : base(accountName, accountNumber, initBalance) { setFeeAmount(feeCharged); }
public void setFeeAmount(double feeCharged) { if (feeCharged >= 0)
{
xxxx.xxxxxxxxxx = xxxxxxxxxx;
}
xxxx
{
xxxx.xxxxxxxxxx = 0;
Preview Program.cs
xxxxx (!xxxxxxxx)
{
xxxxxxx.xxxxx(xxxxxxx);
xxx
{
amount = double.Parse(Console.ReadLine()); // get amount if (amount > 0) { validate = true; } else { Console.WriteLine(“Invalid amount”); } } catch (Exception e) {
xxxxxxx.xxxxxxxxx(“xxxxxxx xxxxxx”);
}
}
xxxxxx xxxxxx;
}
Preview SavingsAccount.cs
xxxxxxx xxxxxx xxxxxxxxxxxx { xxx; xxx; }
// xxxxxxx xxxxxxxxx
xxxxxx xxxxxxxxxxxxxx()
{
}
public SavingsAccount(string accountName, int accountNumber, double initBalance, double interestRate) : base(accountName, accountNumber, initBalance) { setInterestRate(interestRate); }
public void setInterestRate(double interestRate) { if (interestRate >= 0) {
xxxx.xxxxxxxxxxxx = xxxxxxxxxxxx;
}
xxxx
{
xxxx.xxxxxxxxxxxx = 0;
}
Price: $19
Buy Now
Checkout
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 6 – $19.00
CSIS 209 Programming Assignment 7 – $19.00
CSIS 209 Programming Assignment 8 – $25.00
Add to Cart
Checkout
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 4
CSIS 209 Programming Assignment 5
CSIS 209 Programming Assignment 7
CSIS 209 Programming Assignment 8

Reviews

There are no reviews yet.

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