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]
2 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]2 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
A 300 mm long steel bar with a square cross section (25 mm per edge) is pulled in tension with a load of 83,051 N , and experien
umka2103 [35]

Answer:

the answer is attached with required units.

Explanation:

5 0
2 years ago
Create a document that includes a constructor function named Company in the document head area. Include four properties in the C
Stella [2.4K]

I have added the answer as a pic due to difficulties pasting the text here.

3 0
3 years ago
What is the mass of a brass axle that has a volume of 0.318 cm? ​
NeX [460]

Answer:

2.7g

Explanation:

the mass of a brass axle that has a volume of 0.318 cm is 2.7g.

8 0
2 years ago
Quinn’s relatives relayed a story about putting on a headset and seeing a digital world that they could walk around in and explo
Kryger [21]

Answer:

I know it is C)Virtual reality

Explanation:

Look at the clues

story about putting on a headset ( virtual reality head set!)

seeing a digital world (A virtual reality world)

they could walk around in (Fake walking you are basically jogging in place)

explore in order to see what ancient Benin looked like (Looking at a real place only digitally)

as if they were really there ( they think they are actually there)

The only reason I know all of this is because I have done virtual reality multiple times and I LOVED it SUPER fun ( I was doing archery) :) Hope this helps!

6 0
2 years ago
Read 2 more answers
LUNES MARTES MIÉRCOLES JUEVES VIERNES SÁBADO DOMINGO
scZoUnD [109]

Answer:

si

Explanation:

8 0
3 years ago
Other questions:
  • Air enters a horizontal, constant-diameter heating duct operating at steady state at 290 K, 1 bar, with a volumetric flow rate o
    15·2 answers
  • How many volts does one cell produce?
    14·2 answers
  • How to go about the designing of a multirange voltmeter​
    8·1 answer
  • Consider uniaxial extension of a test specimen. It has gauge length L = 22 cm (the distance between where it is clamped in the t
    6·1 answer
  • Where you live might affect how often you change your cabin air filter.<br> True<br> False
    8·1 answer
  • Give six reasons why farmers cultivate on small land​
    5·1 answer
  • Please read and an<br><br> 3. Many Jacks use hydraullc power.<br> A) O True<br> B) O False
    13·1 answer
  • How can you contribute to achieved the mission of NSTP during pandemic in your society?
    7·1 answer
  • Airbags may deploy in the<br> of the passenger or<br> driver, or from the<br> of the vehicle.
    6·1 answer
  • During welding in the vertical position, the torch angle can be varied to control sagging.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!