Programming

Adapted from: Deitel&Deitel (2011).Pearson Education, Inc.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[your name]-Savings-1                  1                              1,000                                                     4%[your name]-Savings-2                  2                              2,000                                                     5%[your name]-Checking-1                               3                              3,000                     3.00[your name]-Checking -2              4                              4,000                     4.00Using a “foreach” loop, iterate over each account in the array.  For each Accountin 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 FullNameproperty.  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 SavingsAccountobject in order to access its CalculateInterest method.  I like to perform this in two steps:  declare a differentvariable 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:SavingsAccounttemp_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();Below is an example of the output.  Try to make your output as similar as possible to that shown below.Adapted from: Deitel&Deitel (2011).Pearson Education, Inc.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[your name]-Savings-1                  1                              1,000                                                     4%[your name]-Savings-2                  2                              2,000                                                     5%[your name]-Checking-1                               3                              3,000                     3.00[your name]-Checking -2              4                              4,000                     4.00Using a “foreach” loop, iterate over each account in the array.  For each Accountin 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 FullNameproperty.  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 SavingsAccountobject in order to access its CalculateInterest method.  I like to perform this in two steps:  declare a differentvariable 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:SavingsAccounttemp_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();Below is an example of the output.  Try to make your output as similar as possible to that shown below.

Place a similar order with us or any form of academic custom essays related subject and it will be delivered within its deadline. All assignments are written from scratch based on the instructions which you will provide to ensure it is original and not plagiarized. Kindly use the calculator below to get your order cost; Do not hesitate to contact our support staff if you need any clarifications.

Type of paper Academic level Subject area
Number of pages Paper urgency Cost per page:
 Total:

Whatever level of paper you need – college, university, research paper, term paper or just a high school paper, you can safely place an order.

Page Navigation