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 to 4 assigned to NUM_VALS
int[] origList = new int[NUM_VALS];
int[] offsetAmount = new int[NUM_VALS];
int i;
//two arrays origList[] and offsetAmount[] get assigned their 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=""; // variable for storing the product results
for(i = 0; i <= origList.length - 1; i++){
/* iterates from 0 to the end of origList */
/* multiplies each origList entry with the corresponding offsetAmount entry, stores results in product */
product+= Integer.toString(origList[i] *= offsetAmount[i]) + " "; }
System.out.println(product); }}
Output:
80 180 80 400
Explanation:
If you wish to print the product of origList alongside offsetAmount values vertically, this can be done in this manner:
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 is shown with the output as a screenshot along with the example's input.