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
3 MAOP stands for which of the following?
raketka [301]

Answer:

MAOP Master of Arts in Organizational Psychology (various universities)

MAOP Maximum Allowable Operating Pressure

MAOP Mid-Atlantic Association of Oracle Professionals

MAOP Mid Atlantic Oncology Program

MAOP Maryland Association of Osteopathic Physicians

MAOP Master Air Operations Planner

MAOP Meharry Association of Office Personnel

MAOP Managers' Annual Operating Plan

MAOP Military Assistance Officer Program (US DoD)

Explanation:

3 0
3 years ago
A scale model is 4th the size of the pump. Determine the power ratio of the pump and its scale model if the ratio of the heads i
vredina [299]

Given:

size of scale model = 4(size of pump)

power ratio of pump and scale model = 5:1

Solution:

Let the diameter of scale model and pump be d_{s} and d_{p} respectively

and head be  H_{s} and  H_{p} respectively

Now, power, P is given as a function of head(H) and dischagre(Q)

P = \rho gQH                  (1)

From eqn (1):

P \propto QH

and

QH \propto \sqrt{H}D^{2}

So,

P \propto H^{\frac{3}{2}} D^{2}

Therefore,

\frac{P_{s}}{P_{p}} = \frac{D_{s}^{2} H_{s}^{\frac{3}{2}}}{D_{p}^{2} H_{p}^{\frac{3}{2}}}

\frac{P_{s}}{P_{p}} = \frac{D_{s}^{2} H_{s}^{\frac{3}{2}}}{D_{p}^{2} H_{p}^{\frac{3}{2}}}

\frac{P_{s}}{P_{p}} = \frac{1^{2}\times 5^{\frac{3}{2}}}{4^{2}\times 1^{\frac{3}{2}}}

\frac{P_{s}}{P_{p}} = \frac{5\sqrt{5}}{16}

{P_{s}}:{P_{p}} = {5\sqrt{5}}:{16}

8 0
3 years ago
Which option identifies the type of power system Tommy will design in the following scenario?
Sedaia [141]

Answer:

diagram of an electrical curcuit

an sketch of an HVAC system

Also 3D image of a hydrualic piston

se

7 0
3 years ago
How might constraints and trade-offs affect the final design of a bridge?
Rainbow [258]

Answer:

It will limit the materials for your bridge which could cause damage to your bridge

Explanation:

4 0
3 years ago
Read 2 more answers
Given the following phasors and the information related to the frequency of that phasor, provide the corresponding time-domain r
Evgesh-ka [11]

Answer:

Explanation:

In Engineering and Physics a Phasor That is a portmanteau of phase vector, is a complex number that represents a sinusoidal function whose Amplitude (A), Angular Frequency (ω), and Initial Phase (θ) are Time-invariant.

For the step by step solution to the question you asked, go through the attached documents.

4 0
3 years ago
Other questions:
  • A large well-mixed tank of unknown volume, open to the atmosphere initially, contains pure water. The initial height of the solu
    12·1 answer
  • Some of the wiring under the hood of a hybrid electric vehicle is encased in bright orange covering. That indicates a
    11·1 answer
  • A particle travels along a straight line with a velocity v = (12 – 3t2) m/s. When t = 1 s, the particle is located 10 m to the l
    5·1 answer
  • Which of the following is an example of seeking accreditation?
    7·1 answer
  • Which of the following is a advantage of a chain and sprocket over a pulley and belt system?
    7·1 answer
  • The chart describes four people’s credit histories.
    5·2 answers
  • Which of the following is NOT an example of a direct cost of workplace injuries?
    5·1 answer
  • According to the video, what are some tasks that Construction Managers perform? Check all that apply.
    9·2 answers
  • 2) What kinds of food can you eat in space?
    14·2 answers
  • 6. The humanistic perspective focuses on free will, Free will is your ability to OA. believe what others believe. B. make your o
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!