answer.
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
referring to either the CMS file or code book index, what is the cross reference for reduction of a dislocation?
Oksi-84 [34.3K]

Answer:

reposition

Explanation:

if you go to your icd 10 pcs index located on page 1 then  look up reduction the subterm is of a dislocation which leads you to the answer reposition

4 0
2 years ago
CHALLENGE ACTIVITY 1.4.1: Basic syntax errors. Type the statements. Then, correct the one syntax error in each statement. Hints:
Lunna [17]

Answer:

Lets check each statement for the errors.

Explanation:

System.out.println("Predictions are hard.");

This statement has no syntax errors. When this statement is executed the following line will be displayed:

Predictions are hard.

System.out.print("Especially ');

This statement is missing the closing quotation mark. A single quotation mark is placed instead of double quotation mark in the statement.

The following error message will be displayed when this program statement will be compiled:

Main.java:15: error: unclosed string literal

String literals use double quotes. So to correct this syntax error, the statement should be changed as follows:

System.out.print("Especially");

The output of this corrected line is as following:

Especially

System.out.println("about the future.").

In this line a period . is placed at the end of the statement instead of a semicolon ; but according to the syntax rules statements should end in semicolons.

The error message displayed when this line is compiled is as following:

Main.java:15: error: ; expected

Main.java:15: error: not a statement

So in order to correct this syntax error the statement should be changed as following:

System.out.println("about the future.");    

The output of this corrected line is as following:

about the future

System.out.println("Num is: " - userName);

There is a syntax error in this statement because of - symbol used instead of +

+ symbol is used to join together a variable and a value a variable and another variable in a single print statement.

The error message displayed when this line is compiled is as following:

Main.java:13: error: bad operand types for binary operator '-'

So in order to correct this syntax error the statement should be changed as following:

System.out.println("Num is: " + userName);

This line will print two things one is the string Num is and the other is the value stored in userName variable.

So let userName= 5 then the output of this corrected line is as following:

Num is: 5

8 0
2 years ago
Determine the deflection at the center of the beam. Express your answer in terms of some or all of the variables LLL, EEE, III,
Rom4ik [11]

Answer:

See explanations for step by step procedures to get answer.

Explanation:

Given that;

Determine the deflection at the center of the beam. Express your answer in terms of some or all of the variables LLL, EEE, III, and M0M0M_0. Enter positive value if the deflection is upward and negative value if the deflection is downward.

4 0
2 years ago
A heat pump operates on a Carnot heat pump cycle with a COP of 12.5. It keeps a space at 24°C by consuming 2.15 kW of power. Det
Vinil7 [7]

Answer:

a) T_{L} = 273.378\,K\,(0.228\,^{\textdegree}C), b) \dot Q_{H} = 26.875\,kW

Explanation:

a) The Coefficient of Performance of the Carnot Heat Pump is:

COP_{HP} = \frac{T_{H}}{T_{H}-T_{L}}

After some algebraic handling, the temperature of the cold reservoir is determined:

T_{H}-T_{L} = \frac{T_{H}}{COP_{HP}}

T_{L} = T_{H}\cdot \left(1-\frac{1}{COP_{HP}}  \right)

T_{L} = (297.15\,K)\cdot \left(1-\frac{1}{12.5}\right)

T_{L} = 273.378\,K\,(0.228\,^{\textdegree}C)

b) The heating load provided by the heat pump is:

\dot Q_{H} = COP_{HP}\cdot \dot W

\dot Q_{H} = (12.5)\cdot (2.15\,kW)

\dot Q_{H} = 26.875\,kW

4 0
2 years ago
print('Predictions are hard.") print(Especially about the future.) user_num = 5 print('user_num is:' user_num)
Bas_tet [7]

Answer:

The correct code is given below:-

print("Predictions are hard.")

print("Especially about the future.")

user_num = 5

print("user_num is:", user_num)

7 0
2 years ago
Other questions:
  • The hot water needs of an office are met by heating tab water by a heat pump from 16 C to 50 C at an average rate of 0.2 kg/min.
    5·1 answer
  • The pump of a water distribution system is powered by a 6-kW electric motor whose efficiency is 95 percent. The water flow rate
    5·1 answer
  • An optical mouse originally cost $31.85. Before it was removed from the store, it underwent the following changes in price. 27%
    8·2 answers
  • Two metallic terminals protrude from a device. The terminal on the left is the positive reference for a voltage called vx (the o
    9·2 answers
  • A bankrupt chemical firm has been taken over by new management. On the property they found a 20,000-m3 brine pond containing 25,
    13·1 answer
  • 15. A cold-chamber die-casting machine operates automatically, supported by two industrial robots.The machine produces two zinc
    9·2 answers
  • Water enters a circular tube whose walls are maintained at constant temperature at specified flow rate and temperature. For full
    8·1 answer
  • The rectangular frame is composed of four perimeter two-force members and two cables AC and BD which are incapable of supporting
    9·1 answer
  • 5. Which of these materials in a shop contain metals and toxins and can pollute the environment? A) Antifreeze B) Solvents C) Ba
    9·2 answers
  • What term describes a guardrail system
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!