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:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education