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...
-
Compare Ancient Female Rulers. Compare the Tang Empress Wu Zetian (also known as Empress Wu or as Wu Zhao; ruled China around 690-705 AD) with either the Pharaoh Cleopatra (ruled Egypt around 51-31...
-
Write a program that uses multiple trapezoidal rule to compute the integral Your program should automatically generate a plot of I versus the number n of trapezoids used to compute the answer up to a...
-
7. CPA QUESTION A principal will not be liable to a third party for a tort committed by an agent: a. Unless the principal instructed the agent to commit the tort b. Unless the tort was committed...
-
Cost Behavior and Cost-Volume-Profit Analysis for Many Glacier Hotel The purpose of this integrated exercise is to demonstrate the interrelationship between cost estimation techniques and subsequent...
-
Visit Professor Kenneth French??s data library:http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html- Download the monthly value-weighted stock returns of 48industry portfolios 0...
-
A child appears to be suffering from I-cell disease, but when a sample of his proteins (lane 3* below), isolated from skin fibroblasts, is compared to protein samples from fibroblasts of his healthy...
-
Due to unstable food prices and erratic food shortages, it is not easy to maintain profitable menu pricing while managing a complex inventory system. The current workforce requires higher wages while...
-
Discuss two ways ( each ) that the mobile phone industry and healthcare industry might be transformed through digital disruption.
-
Discuss and explain what conflict resolution or handling methods will utilize to resolve dysfunctional conflicts within your project team.
-
Discuss how a foundation in physical activity enhances the understanding and management of sports organizations.
-
Choose one of the scenarios posted below and apply the Step-Wise approach. In this assignment, you are essentially demonstrating your understanding of applied ethics and determining an ethical...
-
Discuss the various Leadership Styles that are generally implemented by Ranking Officials in the American Law Enforcement Profession. Which Leadership Style(s) do Men generally follow? - Give a...
-
when developing a corporate sustainability program, its important to determine the areas with the highest environmental impact. what ia the best tool for determing this
-
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...
-
John Aristote LP is an audit frm based in Dublin (Ohio). In 2017, the frm was hired to compile the fnancial statements of Reggie Inc., a nonpublic entity based within the same state. Reggie Inc....
-
The auditor can perform an agreed-upon procedure attest engagement provided that: (a) The auditor is independent (b) The auditor and the specified parties agree upon the procedures performed or to be...
-
In an agreed-upon procedure, the auditor is responsible for all the below, except: (a) To carry out the procedures and report the findings in accordance with the general, fieldwork, and reporting...
Study smarter with the SolutionInn App