Integer arrays firstArr and resetArr are read from input, each containing two elements. If an element...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Integer arrays firstArr and resetArr are read from input, each containing two elements. If an element in firstArr is not a multiple of the corresponding element in resetArr, replace the element in firstArr with the corresponding element in resetArr times 2. Ex: If the input is: 17 14 87 then the output is: 16 14 Note: Given integers A and B, A is a multiple of B only if A % B == 0. 1 import java.util.Scanner; s n 10 ĐÓ J ơn ii Đi một hạt 2 3 public class ReplaceNumbers { 4 5 6 7 8 9 10 HP 11 12 13 14 15 16 12 17 public static void main(String[] args) { Scanner scnr = new Scanner(System.in); final int NUM_VALS = 2; int[] firstArr = new int [NUM_VALS]; int[] resetArr = new int [NUM_VALS]; int i; for (i = 0; i < NUM_VALS; ++i) { scnr.nextInt (); firstArr[i] = } for (i = 0; i < NUM_VALS; ++i) { resetArr[i] scnr.nextInt (); } = 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26} } for (i = 0; i < NUM_VALS; ++i) { firstArr[i] = scnr.nextInt (); } for (i = 0; i < NUM_VALS; ++i) { resetArr[i] = scnr.nextInt(); } /* Your code goes here */ for (i = 0; i < firstArr.length; ++i) { System.out.print(firstArr[i] + "); } System.out.println(); 5 4 Integer arrays firstArr and resetArr are read from input, each containing two elements. If an element in firstArr is not a multiple of the corresponding element in resetArr, replace the element in firstArr with the corresponding element in resetArr times 2. Ex: If the input is: 17 14 87 then the output is: 16 14 Note: Given integers A and B, A is a multiple of B only if A % B == 0. 1 import java.util.Scanner; s n 10 ĐÓ J ơn ii Đi một hạt 2 3 public class ReplaceNumbers { 4 5 6 7 8 9 10 HP 11 12 13 14 15 16 12 17 public static void main(String[] args) { Scanner scnr = new Scanner(System.in); final int NUM_VALS = 2; int[] firstArr = new int [NUM_VALS]; int[] resetArr = new int [NUM_VALS]; int i; for (i = 0; i < NUM_VALS; ++i) { scnr.nextInt (); firstArr[i] = } for (i = 0; i < NUM_VALS; ++i) { resetArr[i] scnr.nextInt (); } = 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26} } for (i = 0; i < NUM_VALS; ++i) { firstArr[i] = scnr.nextInt (); } for (i = 0; i < NUM_VALS; ++i) { resetArr[i] = scnr.nextInt(); } /* Your code goes here */ for (i = 0; i < firstArr.length; ++i) { System.out.print(firstArr[i] + "); } System.out.println(); 5 4
Expert Answer:
Answer rating: 100% (QA)
Heres the remaining code import javautilScanner public class Replacenumbers ... View the full answer
Related Book For
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts
Posted Date:
Students also viewed these programming questions
-
9.1 Exercise (JDK Source Code): Extract the source code of the class Math from the JDK source code ("$JAVA_HOME" "src.zip" "Math.java" under folder "java.lang"). Study how constants such as E and...
-
Perez Manufacturing Company began operations on January 1. During the year, it started and completed 1,740 units of product. The financial statements are prepared in accordance with GAAP. The company...
-
Calculating Cash Collections the following is the sales budget for Duck-n-Run, Inc., for the first quarter of 2006. Credit sales are collected as follows: 65 percent in the month of the sale 20...
-
Refer to the information presented for Diatessaron Inc. in P17-11A. Additional information: 1. All purchases of inventory are on credit. 2. Accounts payable is used only to record purchases of...
-
A Bell-Coleman cycle is a reversed: (a) Brayton cycle (b) Atkinson cycle (c) Ericsson cycle (d) Carnot cycle
-
The postanesthesia care area (recovery room) at St. Lukes Hospital in Maumee, Ohio, was recently enlarged. The hope was that with the enlargement the mean number of patients per day would be more...
-
Kirinyaga Hydraulic Contractors in partnership with the World Bank are embarking on a water project in Mukurweini Division. They are contemplating to gauge the benefits of the project through cost-...
-
Use the construction in the proof of Theorem 1.45 to give the state diagrams of NFAs recognizing the union of the languages described in a. Exercises 1.6a and 1.6b. b. Exercises 1.6c and 1.6f....
-
Given the function 2 f(x) = x coS I and f'(2) needs to be evaluated. Using the Richardson's h" extrapolation method, obtain T, after using the central difference quotient with h = 0.025 and h =...
-
Enter the specific amount of time spent as well as key descriptors so you remember important details. Be sure to indicate what specific content you consumed as well as how you consumed it (For...
-
Assume you have been put in charge of a new task force to determine the cause of lost sales in the Western region of your plastics manufacturing firm. As the leader of the task force, it is your job...
-
As an Administrative manager you observe that there is a gap in employee EDUCATION/TRAINING in your company. Some staff have not acquired the needed training, and some of them have skills that are...
-
Write three paragraphs. A reflection is focused on your feelings and how you can apply what you learned in your teams. Reflections must include: Three things that you plan to implement in your future...
-
My topic is domestic violence for my paper. What have you found in your research of your topic (please state topic again in your reply) that has surprised you? Provide what kind of reform you are...
-
T F 23. The full cross-sectional area of cellular metal floor raceway may be used if AC cable is used. 24. Luminaires that are designed to be supplied by direct current shall be for DC operation. 25....
-
Draw the appropriate control flow graph of the given pseudocode.Make sure to only use one number for blocks of code which are all sequential and when the first line is executed, all of those lines...
-
Michael, a minor, operates a one-man automobile repair shop. Anderson, having heard of Michaels good work on other cars, takes her car to Michaels shop for a thorough engine overhaul. Michael, while...
-
Conrad and Darby were competitors in the business of dehairing raw cashmere, the fleece of certain Asiatic goats. Dehairing is the process of separating the commercially valuable soft down from the...
-
Explain what trade secrets protect and how they may be infringed.
-
Michael Rau founded Michaels Fishing Supplies on 1 July 2019. The adjusted trial balance at 30 June 2020 (the end of the financial year) is shown below. Required (a) Prepare closing entries to be...
-
You are provided with the worksheet for Norman Pty Ltd for the year ended 30 June 2019. The adjustments have already been made and the worksheet begins with the adjusted trial balance. Assume all...
-
Moore Manufacturing Pty Ltd makes refrigerators and is trying to determine the cost of its ending work in process. The accountant has put together the following data for the year ended 30 June 2019....
Study smarter with the SolutionInn App