1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
fenix001 [56]
3 years ago
13

Multiply each element in origList with the corresponding value in offsetAmount. Print each product followed by a space.Ex: If or

igList = {4, 5, 10, 12} and offsetAmount = {2, 4, 7, 3}, print:8 20 70 36 import java.util.Scanner;public class VectorElementOperations {public static void main (String [] args) {final int NUM_VALS = 4;int[] origList = new int[NUM_VALS];int[] offsetAmount = new int[NUM_VALS];int i;origList[0] = 20;origList[1] = 30;origList[2] = 40;origList[3] = 50;offsetAmount[0] = 4;offsetAmount[1] = 6;offsetAmount[2] = 2;offsetAmount[3] = 8;/* Your solution goes here */System.out.println("");}}

Engineering
1 answer:
n200080 [17]3 years ago
8 0

Answer:

Here is the JAVA program:  

import java.util.Scanner; // to take input from user

public class VectorElementOperations {

public static void main(String[] args) {

final int NUM_VALS = 4; // size is fixed that is 4 and assigned to NUM_VALS

int[] origList = new int[NUM_VALS];

int[] offsetAmount = new int[NUM_VALS];

int i;

//two lists origList[] and offsetAmount[] are assigned values

origList[0] = 20;

origList[1] = 30;

origList[2] = 40;

origList[3] = 50;

offsetAmount[0] = 4;

offsetAmount[1] = 6;

offsetAmount[2] = 2;

offsetAmount[3] = 8;

String product=""; // product variable to store the product of 2 lists

for(i = 0; i <= origList.length - 1; i++){

/* loop starts with i at 0th position or index and ends when the end of the origList is reached */

/* multiples each element of origList to corresponding element of offsetAmount and stores result in the form of character string in product*/

   product+= Integer.toString(origList[i] *= offsetAmount[i]) + " ";  }

 System.out.println(product); }}   //displays the product of both lists

Output:

80 180 80 400

Explanation:

If you want to print the product of origList with corresponding value in offsetAmount in vertical form you can do this in the following way:

import java.util.Scanner;

public class VectorElementOperations {

public static void main(String[] args) {

final int NUM_VALS = 4;

int[] origList = new int[NUM_VALS];

int[] offsetAmount = new int[NUM_VALS];

int i;

origList[0] = 20;

origList[1] = 30;

origList[2] = 40;

origList[3] = 50;

offsetAmount[0] = 4;

offsetAmount[1] = 6;

offsetAmount[2] = 2;

offsetAmount[3] = 8;

for(i = 0; i <= origList.length - 1; i++){

 origList[i] *= offsetAmount[i];

System.out.println(origList[i]); } }}

Output:

80                                                                                                                            

180                                                                                                                          

80                                                                                                                            

400

The program along with the output is attached as screenshot with the input given in the example.

You might be interested in
Match each context to the type of the law that is most suitable for it.
Bas_tet [7]

Answer:

sorry i dont understand the answer

Explanation:

but i think its a xd jk psml lol

5 0
3 years ago
Physical items produced in an economy are known as
Arisa [49]
I don’t think I know that
6 0
3 years ago
Large quantities of liquefied natural gas (LNG) are shipped by ocean tanker. At the unloading port, provision is made for vapori
kodGreya [7K]

Answer:

yfyuhvckydfxcvkjyfvgrjfvhkhgfyhtfhchghjgyfvyghvhygvkuh

Explanation:

6 0
4 years ago
Which of the following types of protective equipment protects workers who are passing by from stray sparks or metal while anothe
lawyer [7]

A protective equipment which protects workers who are passing by from stray sparks or metal while another worker is welding is: E. Welding Screens.

A wielder refers to an individual who is saddled with responsibility of joining two or more metals together by wielding.

During the process of wielding, sparks and minute metallic objects are produced, which are usually hazardous to both the wielder and other workers within the vicinity.

Hence, the following protective equipment are meant to be worn or used directly by a wielder (worker) who is wielding:

  • Visors.
  • Goggles.
  • Protective clothing.
  • Dark walls.

However, a protective equipment which protects other workers who are passing by from stray sparks or metallic objects while wielder (worker) is welding is referred to as welding screens.

Find more information: brainly.com/question/15442363

4 0
3 years ago
What are the specifications state that all work shall be done?
Elodia [21]

Answer:

The description including its scope is presented throughout the section below.

Explanation:

  • Such operation must be carried out in compliance with all statutes, legislation, building standards, guidelines, and rules relating to that same task, not all of which are restricted to either the U.S Disability Act, the Ecological laws as well as the workplace Safety Act as modified.
  • This same consultant shall appoint and could be completely liable for almost all processes and sequences just for conducting the Job.
4 0
3 years ago
Other questions:
  • ): drivers must slow down from 60 to 40 mi/hr to negotiate a severe curve. A warning sign is visible for a distance of 120 ft. H
    7·1 answer
  • In case the Rectilinear distance is considered, find the optimal coordinates (X,Y) of new facility. Q2) Show and label the exist
    7·1 answer
  • Select all that apply.
    13·1 answer
  • Based on parameters such as the materials shear modulus, diameter of the wire, mean coil diameter, and number of active coils (a
    11·1 answer
  • A generator is to be driven by a small Pelton wheel with a head of 91.5m at inlet to the nozzle and discharge of 0.04m^3/s. The
    6·1 answer
  • the diagram shows an electrical circuit when the switch is open and closed which series of energy transformation occurs when the
    15·1 answer
  • At steady state, the power input of a refrigeration cycle is 500 kW. The cycle operates between hot and cold reservoirs which ar
    13·1 answer
  • Explain why Chloe's design needs to be redone in the following scenario, and recommend the techniques she needs to include in he
    15·2 answers
  • I will Brainliest
    7·2 answers
  • error: request for member 'setcursor' in 'oled', which is of non-class type 'adafruit ssd1306(int, int)' oled.setcursor(x, accel
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!