Integer arrays origArr and cleaning Arr are read from input, each containing three elements. If an...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Integer arrays origArr and cleaning Arr are read from input, each containing three elements. If an element in cleaningArr is equal to 1, replace the corresponding element in origArr with -1. Otherwise, multiply the corresponding element in origArr by 2. Ex: If the input is: 44 17 46 43 1 35 then the output is: 88 -1 92 3 public class ResetNumbers { 4 public static void main(String[] args) { min 1000HN MAS 5 6 8 9 10 ALL111111 11 12 13 14 15 16 6789 17 18. 19 Scanner scnr = new Scanner(System.in); final int NUM_VALS = 3; int[] origArr = new int [NUM_VALS]; int[] cleaningArr = new int [NUM_VALS]; int i; for (i 0; i < NUM_VALS; ++i) { origArr[i] scnr.nextInt (); = } for (i = 0; i < NUM_VALS; ++i) { cleaningArr[i] scnr.nextInt (); = } /* Your code goes here */ 12 13 14 PPPPP 15 min 10 000 16 17 18 19 20 21 UNNNN. 22 23 24 25 } 26} origArr[i] = scnr.nextInt (); } for (i = 0; i < NUM_VALS; ++i) { cleaningArr[i] scnr.nextInt (); } * Your code goes here */ for (i = 0; i < origArr.length; ++i) { System.out.print (origArr[i] + " "); } System.out.println(); 1 = 2 3 Integer arrays origArr and cleaning Arr are read from input, each containing three elements. If an element in cleaningArr is equal to 1, replace the corresponding element in origArr with -1. Otherwise, multiply the corresponding element in origArr by 2. Ex: If the input is: 44 17 46 43 1 35 then the output is: 88 -1 92 3 public class ResetNumbers { 4 public static void main(String[] args) { min 1000HN MAS 5 6 8 9 10 ALL111111 11 12 13 14 15 16 6789 17 18. 19 Scanner scnr = new Scanner(System.in); final int NUM_VALS = 3; int[] origArr = new int [NUM_VALS]; int[] cleaningArr = new int [NUM_VALS]; int i; for (i 0; i < NUM_VALS; ++i) { origArr[i] scnr.nextInt (); = } for (i = 0; i < NUM_VALS; ++i) { cleaningArr[i] scnr.nextInt (); = } /* Your code goes here */ 12 13 14 PPPPP 15 min 10 000 16 17 18 19 20 21 UNNNN. 22 23 24 25 } 26} origArr[i] = scnr.nextInt (); } for (i = 0; i < NUM_VALS; ++i) { cleaningArr[i] scnr.nextInt (); } * Your code goes here */ for (i = 0; i < origArr.length; ++i) { System.out.print (origArr[i] + " "); } System.out.println(); 1 = 2 3
Expert Answer:
Answer rating: 100% (QA)
import javautilScanner public class ResetNumbers public static void main... View the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
The main effect of Walmart's hierarchical functional organisational structure is the ability of corporate managers to easily influence the entire organisation. In order for Walmart's corporate...
-
Herbs Pty Ltd is considering investing in a new herb packaging machine. The machine is estimated to cost $80,000 which can last for 7 years before it becomes too costly to maintain and can be sold...
-
Calculating Cycles Consider the following financial statement information for the Bulldog Icers Corporation: Calculate the operating and cash cycles. How do you interpret your answer? Beginning...
-
Many investors today prefer the cash flow statement over the income statement. They believe that cash-based data are a better measure of performance than accrual-based data because the estimates and...
-
The refrigerating system of passenger air craft works on reversed: (a) Brayton cycle (b) Atkinson cycle (c) Ericsson cycle (d) Carnot cycle
-
Six Twelve, Inc., is considering opening up a new convenience store in downtown New York City. The expected annual revenue at the new store is $800,000. To estimate the increase in working capital,...
-
What can you do to increase the performance of an embedded system?
-
Hemming Company reported the following current-year purchases and sales for its only product. Date Activities January 11 Beginning inventory. January 10 Sales March 14 March 151 July 30 October 5...
-
Assume that the current spot rate of the Swiss Franc (currency of Switzerland) is $0.62 US dollars (USD).American sports footwear and apparel company New Balance has purchased a 90-day forward...
-
Match the words with the term Question 1 options: semi-variable costs difference between revenue and total costs variable costs non-cash expense How are manufacturing overhead costs allocated and...
-
AMBC (Pty) Ltd invested R 10 000 on a project. The interest rate for the loan at the bank is 9%. Calculate the NPV after four years if the return on investment is: Year 1: R 1 000 Year 2: R 2 000...
-
For uniformity purposes, there is already a given set of procedures and an audit program template. Arrange the audit procedures on its logical sequence and prepare an audit program guide using the...
-
What are the primary responsibilities of an accountant in an organization? How does an accountant contribute to the financial health and stability of a company?
-
Michael and Diana are married and have five children: Michael II , Zena, Amara, Bryan, and Skyla. They live at 1 2 0 Main Street, Flushing NY 1 1 4 2 5 . Michael is a lawyer working for a Native...
-
25. For a given set of 4 data points, Ex = 2, Exy = 16, Ex = 6, Ey 206. If the slope of the best fit line y = mx + b is 5, what is b? 8 None of the above. 26. Kathy needed to find the inverse of a 3...
-
The MIT Sloan School of Management is one of the leading business schools in the U.S. The following table contains the tuition data for the masters program in the Sloan School of Management. a. Use...
-
Suppose that, instead of sorting an array, we just require that the elements increase on average. More precisely, we call an n-element array A k-sorted if, for all i = 1, 2, . . . ,n ? k, the...
-
Consider the following closest-point heuristic for building an approximate traveling-salesman tour whose cost function satisfies the triangle inequality. Begin with a trivial cycle consisting of a...
-
Construct a computation dag for which one execution of a greedy scheduler can take nearly twice the time of another execution of a greedy scheduler on the same number of processors. Describe how the...
-
The financial statements for the business of Jets Ski Equipment are shown below. Additional information 1. All purchases and sales of inventories are on credit. 2. On 1 July 2019, J. Waters injected...
-
Some of the most recent financial statements for Hyland Pty Ltd are shown below. Additional information 1. All purchases and sales of inventories are on credit. 2. On 1 July 2020, the shareholders...
-
The comparative statements of financial position of Cresta Ltd as at 30 June 2019 and 2020, and the income statement and statement of changes in equity for the year ended 30 June 2020 are shown...
Study smarter with the SolutionInn App