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
How is TEL (total equivalent length) measured and calculated? .​
ollegr [7]
Measure the longest circuit and add 50% for fittings and terminal units.
3 0
3 years ago
A mass of 5 kg of saturated water vapor at 100 kPa is heated at constant pressure until the temperature reaches 200°C.
Alex73 [517]

Answer: you can watch a video on how to solve this question on you tube

6 0
3 years ago
How can I draw this image in 2D form
Ket [755]

Answer:

no it is not 2D

Explanation:

it is 3D

ok so follow these steps

- make hole

-make square

-make triangle

ok now your figure is ready

5 0
3 years ago
A gas metal arc welder is also known as a _____ welder.<br> A) TIGB) GTAWC) GMAWD) Resistance spot
nignag [31]

Answer:

GMAW

Explanation:

It's literally the initials of that type of welding

7 0
3 years ago
If a car sits out in the sun every day for a long time can light from the sun damage the car paint
Reika [66]

Answer:

i think yes it could make the color go lighter

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • 6.15. In an attempt to conserve water and to be awarded LEED (Leadership in Energy and Environmental Design) certification, a 20
    14·1 answer
  • Consider a simple ideal Rankine cycle and an ideal regenerative Rankine cycle with one open feedwater heater. The two cycles are
    15·1 answer
  • What are the causes of electric shock​
    13·1 answer
  • At a certain location, wind is blowing steadily at 10 m/s. Determine the mechanical energy of air per unit mass and the power ge
    5·1 answer
  • You have designed a bone plate that is manufactured via rolling under cold working conditions, and tests show good biocompatibil
    14·1 answer
  • The lattice constant of a simple cubic primitive cell is 5.28 Å. Determine the distancebetween the nearest parallel ( a ) (100),
    13·1 answer
  • Pipe (2) is supported by a pin at bracket C and by tie rod (1). The structure supports a load P at pin B. Tie rod (1) has a diam
    15·1 answer
  • 3.24 Program: Drawing a half arrow (Java) This program outputs a downwards facing arrow composed of a rectangle and a right tria
    12·1 answer
  • A Pelton wheel is supplied with water from a lake at an elevation H above the turbine. The penstock that supplies the water to t
    6·1 answer
  • Tech A says that LED brake lights illuminate faster than incandescent bulbs. Tech B says that LED brake lights have
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!