Having trouble soloving this interconnected part of problem. Just started learning 2d arrays. Need help with the programming part of this question. Part A :- Write a method to subtract two one-dimensional integer arrays and return the result, assuming the two arrays are of the same size. For example, the addition result of {4, 5, 1} and {-1, 2, 9} is {5, 3, -8}. The implementation of the method should be general so that it can return the subtraction result for any two arrays of the same size. The method signature is given as follows:

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 11PE
icon
Related questions
Question

Having trouble soloving this interconnected part of problem. Just started learning 2d arrays. Need help with the programming part of this question.

Part A :- Write a method to subtract two one-dimensional integer arrays
and return the result, assuming the two arrays are of the same size.
For example, the addition result of {4, 5, 1} and {-1, 2, 9} is {5, 3,
-8}. The implementation of the method should be general so that it can
return the subtraction result for any two arrays of the same size. The
method signature is given as follows: 

Part B:- Implement the class SavingsAccount according to the
following UML:

Part C:- Based on the previous SavingsAccount, write a test program
called TestSavingsAccount that should do the following tasks: 

Rest is attatch in image in order. Part A is one image and Part B and C is attatch in second image.

Savings Account
-annual InterestRate: double
-balance: double
The annual interest rate for each saving
account.
The account balance.
+Savings Account(balance: double)
Constructs an account object with a
specified balance.
+calculateMonthlyInterest(): double
Returns the monthly interest. The interest
should be added to savings Balance.
Sets a new annual InterestRate.
+modify InterestRate(annual InterestRate:double):void
+getBalance(): double
+setBalance(balance: double): void
Return the balance.
Set a new balance.
Use a private static data field to store the annualInterestRate for each of the savers. Each
instance of the class contains a private instance data field savingsBalance, indicating the amount
the saver currently has on deposit. Provide method calculateMonthlyInterest to calculate the
monthly interest by multiplying the savingBalance by annualInterestRate divided by 12; this
interest should be added to savingsBalance. Provide a static method modify InterestRate that
sets the annualInterest Rate to a new value. Provide one constructor which takes a double type
parameter to initialize the savingsBalance.
1) Create a savings account object called myAccount with $10,000.
2) Set the annual interest rate as 6%, which is 0.06.
3) Calculate and display monthly interest of the account.
4) Display the new balance of the account.
The original balance is $10000.0
The monthly interest is $50.0
The new balance is $10050.0
A sample output:
Transcribed Image Text:Savings Account -annual InterestRate: double -balance: double The annual interest rate for each saving account. The account balance. +Savings Account(balance: double) Constructs an account object with a specified balance. +calculateMonthlyInterest(): double Returns the monthly interest. The interest should be added to savings Balance. Sets a new annual InterestRate. +modify InterestRate(annual InterestRate:double):void +getBalance(): double +setBalance(balance: double): void Return the balance. Set a new balance. Use a private static data field to store the annualInterestRate for each of the savers. Each instance of the class contains a private instance data field savingsBalance, indicating the amount the saver currently has on deposit. Provide method calculateMonthlyInterest to calculate the monthly interest by multiplying the savingBalance by annualInterestRate divided by 12; this interest should be added to savingsBalance. Provide a static method modify InterestRate that sets the annualInterest Rate to a new value. Provide one constructor which takes a double type parameter to initialize the savingsBalance. 1) Create a savings account object called myAccount with $10,000. 2) Set the annual interest rate as 6%, which is 0.06. 3) Calculate and display monthly interest of the account. 4) Display the new balance of the account. The original balance is $10000.0 The monthly interest is $50.0 The new balance is $10050.0 A sample output:
public static int[] subtract (int[] a, int[] b)
Prompts the user to enter the number of integers (the size of
the arrays),
Initializes two int arrays by user's inputs using two for loops,
Invokes the subtract method,
Displays the subtracted array contents using another for loop.
A sample output:
Pleaes input the number of integers: 3
Pleaes input the integers for the first array:
Enter a number: 4
Enter a number: 5
Enter a number: 1
Pleaes input the integers for the second array:
Enter a number: -1
Enter a number: 2
Enter a number: 9
The subtracted array is:
53-8
Write a main method in the same file that:
Transcribed Image Text:public static int[] subtract (int[] a, int[] b) Prompts the user to enter the number of integers (the size of the arrays), Initializes two int arrays by user's inputs using two for loops, Invokes the subtract method, Displays the subtracted array contents using another for loop. A sample output: Pleaes input the number of integers: 3 Pleaes input the integers for the first array: Enter a number: 4 Enter a number: 5 Enter a number: 1 Pleaes input the integers for the second array: Enter a number: -1 Enter a number: 2 Enter a number: 9 The subtracted array is: 53-8 Write a main method in the same file that:
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT