a. (100pts) Write a method to subtract two one-dimensional integer arrays and return the result, assuming...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
Heres the Java code for the three parts of your assignment a Subtracting two onedimensional integer arrays java import javautilScanner public class Ar... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
ttth Suppose that the sequence of bags {Bn | n N} is recursively enumerated by the computable function e(n, x) = fn(x), [7 marks] Hence prove that the set of all recursive bags cannot be recursively...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
For each of the following demand functions, check whether they satisfy the weak axiom of revealed preferences (WARP) (a) "Random Demand". For any pair of prices p and p2 and income m, the consumer...
-
A small business owner must decide whether to carry flood insurance. She may insure her business for $2 million for $100,000, $1 million for $50,000, or $.5 million for $30,000. Her business is worth...
-
What happens during the accounting cycle?
-
A region of space contains a changing magnetic field given by \(\vec{B}(t)=B_{0} e^{-t / \tau} \hat{k}\), and a circular conducting loop of radius \(R\) lies in this region in the \(x y\) plane. (a)...
-
The income statement for the Timberline Golf Club Inc. for the month ended July 31 shows Service Revenue $16,000; Salaries and Wages Expense $8,400; Maintenance and Repairs Expense $2,500; and Income...
-
31 (i) Explain why the refractive index of any material with respect to air is always greater 1. (ii) In the figure below a light ray travels from air into the semi-circular plastic block. Give a...
-
1. What is price in accounting, and why is it important? 2. Discuss the relationship between price and demand in accounting. 3. What are the primary factors that influence pricing decisions in...
-
Riverside Medical Foundations - California has pledged $150 Million spend over 3 years to be known as "The Harbinger of Good Health". In line with this vision are 5 strategic priorities: (1) Health...
-
A scissors jack for an automobile is shown below. The screw threads exert a force F on the blocks at joints A and B. If F = 700 N, determine the shearing stress on a cross section of the 10-mm-...
-
One major indicator of student success is being in the right major. It is really hard to get motivated toward academic success when you are not enjoying what you are learning about. Be sure to follow...
-
The Organization of the Petroleum Exporting Countries held a meeting due to rising oil prices caused by new sanctions on the Russian invasion of Ukraine. During the meeting, a proposal was introduced...
-
Increase your ability to research current events related to fraud, increase your understanding of a particular type of fraud, and provide an opportunity to evaluate articles about fraud critically....
-
Rita receives a gross pay (before deductions ) of $495.72. Her deductions are $59.60 for federal income tax , $29.00 for FICA , and $29.00 for medical insurance . What is her take-home pay?
-
Choose two matrices A and B with dimension 2 x 2. Calculate det A, det B, and det (AB). Repeat this process until you are able to discover how these three determinants are related. Summarize your...
-
Harold Conners (Social Security number 785-23-9873) lives at 13234 DeMilo Drive, Houston, TX 77052, and is self-employed for 2012. He estimates his required annual estimated tax payment for 2012 to...
-
Professor Patricia (Patty) Pate is retired from the PalmSprings Culinary Arts Academy (PSCAA). She is a single taxpayer and is 68 years old. Patty lives at 98 Colander Street, Henderson, NV 89052....
-
Quince Interests is a partnership with a tax year that ends September 30, 2012. During that year, Potter, a partner, received $3,000 per month as a guaranteed payment, and his share of partnership...
-
Draw a cash flow diagram of any investment that exhibits both of the following properties: 1. The investment has a 4-year life. 2. The investment has a 10 percent/year internal rate of return.
-
What is the internal rate of return of the following cash flow diagram? a. 20 percent b. 18.2 percent c. 17.5 percent d. 15 percent $30 $31 0 1 2 3 $30 $15
-
Quilts R Us (QRU) is considering investing in a new patterning attachment with the cash flow profile shown in the table below. QRU's MARR is 13.5 percent/year. a. What is the internal rate of return...
Study smarter with the SolutionInn App