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
Water is flowing at a rate of 0.15 ft3/s in a 6 inch diameter pipe. The water then goes through a sudden contraction to a 2 inch
Georgia [21]

Answer:

Head loss=0.00366 ft

Explanation:

Given :Water flow rate Q=0.15 \frac{ft^{3}}{sec}

         D_{1}= 6 inch=0.5 ft

        D_{2}=2 inch=0.1667 ft

As we know that Q=AV

A_{1}\times V_{1}=A_{2}\times V_{2}

So V_{2}=\frac{Q}{A_2}

     V_{2}=\dfrac{.015}{\frac{3.14}{4}\times 0.1667^{2}}

     V_{2=0.687 ft/sec

We know that Head loss due to sudden contraction

           h_{l}=K\frac{V_{2}^2}{2g}

If nothing is given then take K=0.5

So head lossh_{l}=(0.5)\frac{{0.687}^2}{2\times 32.18}

                                    =0.00366 ft

So head loss=0.00366 ft

4 0
3 years ago
What is noise definition in physics<br><br>​
Bess [88]

Answer:

Noise or sound is the energy produced by sounding object which can be felt by our hearing organs .

Explanation:

Noise is produced by vibration in a body.

4 0
3 years ago
The formula for calculating risk considering risk perception is ?​
s2008m [1.1K]

Answer:

risk = probability x loss

Explanation:

3 0
3 years ago
An engineering drawing shows the: (A) dimensions, tolerances, cost, and sales or use volume of a component.(B) dimensions, toler
Leto [7]

Answer:

(B) dimensions, tolerances, materials, and finishes of a component.

Explanation:

An engineering drawing :

  An  engineering drawing is a technical drawing which draws the actual component .

An engineering drawing shows

1. Materials

2.Dimensions

3.Tolerance

4.Finishes of a component

Engineering drawing does not shows any information about the cost of component.

So the option B is correct.

3 0
3 years ago
When your complex reaction time is compromised by alcohol, an impaired person's ability to respond to emergency or unanticipated
babunello [35]

Answer:

decreased

Explanation:

when impaired you react slower then you would sober.

3 0
3 years ago
Other questions:
  • g Consider a thin opaque, horizontal plate with an electrical heater on its backside. The front end is exposed to ambient air th
    11·1 answer
  • Air enters the compressor of a cold air-standard Brayton cycle with regeneration and reheat at 100 kPa, 300 K, with a mass flow
    10·1 answer
  • Chemical materials that are transported are called..
    8·1 answer
  • Create a separate function file fieldtovar.m that receives a single structure as an input and assigns each of the field values t
    15·1 answer
  • Which option supports the following scenario?
    14·1 answer
  • Define the Artist class in Artist.py with a constructor to initialize an artist's information. The constructor should by default
    7·1 answer
  • This is hard please help me you will give brainlist
    5·2 answers
  • Which term describes the lowest of a foundation?
    10·1 answer
  • Tires can be recycled instead of thrown out.<br> True<br> False
    13·1 answer
  • A farmer has 12 hectares of land on which he grows corn, wheat, and soybeans. It costs $4500 per hectare to grow corn, $6000 to
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!