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
An AX ceramic compound has the rock salt crystal structure. If the radii of the A and X ions are 0.137 and 0.241 nm, respectivel
Tju [1.3M]

Answer:

c) 1.75 g/cm³

Explanation:

Given that

Radii of the A ion, r(c) = 0.137 nm

Radii of the X ion, r(a) = 0.241 nm

Atomic weight of the A ion, A(c) = 22.7 g/mol

Atomic weight of the X ion, A(a) = 91.4 g/mol

Avogadro's number, N = 6.02*10^23 per mol

Solution is attached below

3 0
3 years ago
Which explanation best summarizes what went wrong during Paul’s cost analysis?
Valentin [98]

Answer:

wut is it

Explanation:

4 0
2 years ago
A 12-ft circular steel rod with a diameter of 1.5-in is in tension due to a pulling force of 70-lb. Calculate the stress in the
padilas [110]

Answer:

The stress in the rod is 39.11 psi.

Explanation:

The stress due to a pulling force is obtained dividing the pulling force by the the area of the cross section of the rod. The respective area for a cylinder is:

A=\pi*D^2/4

Replacing the diameter the area results:

A= 17.76 in^2

Therefore the the stress results:

σ = 70/17.76 lb/in^2 = 39.11 lb/in^2= 39.11 psi

5 0
3 years ago
Use the results of Prob. 5–82 for plane strain near the tip with u 5 0 and n 5 13. If the yieldstrength of the plate is Sy, what
rosijanka [135]

Answer:

Kindly follow the steps as shown below.

Explanation:

8 0
3 years ago
Please help this is due today!!!!!
White raven [17]

Answer:

1:c 2:False

Explanation:

7 0
3 years ago
Other questions:
  • Consider a cylindrical specimen of some hypothetical metal alloy that has a diameter of 11.0 mm. A tensile force of 1550 N produ
    7·1 answer
  • Technician A says that when using an impact wrench to remove a bolt from the front of an engine's crankshaft, the crankshaft mus
    15·1 answer
  • g A 30-m-diameter sedimentation basin has an average water depth of 3.0 m. It is treating 0.3 m3/s wastewater flow. Compute over
    8·1 answer
  • 3 examples of technology transfer pls
    12·2 answers
  • Why dues brainy exist as a learning platform when it is just full of answers and you won't learn anything?
    8·1 answer
  • Why Your first project as the new web designer at Smart Design is to increase web traffic to help boost web orders. Before you b
    6·1 answer
  • using the two transistor analogy to explain what happens when an SCR is supplied with some gate current.​
    15·1 answer
  • Calculate the resistance of a circuit with 1.5 A and 120 V. Use the appropriate formula from the list of formulas on the
    9·1 answer
  • Can someone please help me?
    11·2 answers
  • Tech A says that wiring diagrams are essentially a map of all of the electrical components and their connections. Tech B says th
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!