Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a. (100pts) Write a method to subtract two one-dimensional integer arrays and return the result, assuming the two arrays are of the same size.

imageimage

a. (100pts) 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: public static int[] subtract (int[] a, int[] b) Write a main method in the same file that: 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: 5 3-8 b. (100pts) Implement the class Savings Account according to the following UML: C. Savings Account -annual InterestRate: double -balance: double +Savings Account(balance: double) +calculateMonthlyInterest(): double +modifyInterestRate(annual InterestRate:double):void +getBalance(): double +setBalance(balance: double): void 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 modifyInterestRate that sets the annualInterestRate to a new value. Provide one constructor which takes a double type parameter to initialize the savings Balance. The annual interest rate for each saving account. The account balance. Constructs an account object with a specified balance. (100pts) Based on the previous Savings Account, write a test program called TestSavingsAccount that should do the following tasks: A sample output: Returns the monthly interest. The interest should be added to savingsBalance. Sets a new annual InterestRate. Return the balance. Set a new balance. 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 Grade criteria Grading: Each problem is worth 100 points in total. If your program has any compilation or run time errors, you will receive 0 points. Correct result and output Proper implementation of all features specified in the program Proper style and documentation * Maximum points 80 20

Step by Step Solution

3.55 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

Heres an example of a Java program that includes the requested methods and test program java Copy import javautilScanner public class SavingsAccount p... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

What skills would a project manager need?

Answered: 1 week ago