Write a program that reads two lists of integers from input into two arrays and outputs the sum of multiplying the corresponding list items. The program first reads an integer representing the length of each list, followed by two lists of integers. Ex: If the input is: 3 1 2 3 3 2 1 the program calculates (1 * 3) + (2*2)+(3 * 1) and outputs 10 Ex: If the input is: 4 2 3 4 5 1 1 1 1 the program calculates (2* 1) + (3 * 1) + (4 * 1) + (5 * 1) and outputs 14

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 20PE
icon
Related questions
Question

In Java please. 

Write a program that reads two lists of integers from input into two arrays and outputs the sum of multiplying the corresponding list items.
The program first reads an integer representing the length of each list, followed by two lists of integers.
Ex: If the input is:
3
1 2 3
3 2 1
the program calculates (1 * 3) + (2 * 2) + (3 * 1) and outputs
10
Ex: If the input is:
2 3 4 5
1 1 1 1
the program calculates (2 * 1) + (3 * 1) + (4 * 1) + (5 * 1) and outputs
14
Transcribed Image Text:Write a program that reads two lists of integers from input into two arrays and outputs the sum of multiplying the corresponding list items. The program first reads an integer representing the length of each list, followed by two lists of integers. Ex: If the input is: 3 1 2 3 3 2 1 the program calculates (1 * 3) + (2 * 2) + (3 * 1) and outputs 10 Ex: If the input is: 2 3 4 5 1 1 1 1 the program calculates (2 * 1) + (3 * 1) + (4 * 1) + (5 * 1) and outputs 14
1 import java.util.Scanner;
2
3 public class LabProgram {
4
5
6
7
8
9
10
11
12
13
14}
public static void main(String[] args) {
}
Scanner scnr new Scanner(System.in);
int size;
size = scnr.nextInt();
int[] listA new int[size];
int[] listB
new int[size];
here. */
=
/* Type your code
Develop mode Submit mode
// List A
// List B
Run your program as often as you'd like, before submitting for grading. Below, type any needed
input values in the first box, then click Run program and observe the program's output in the
second box.
Enter program input (optional)
If your code requires input values, provide them here.
Transcribed Image Text:1 import java.util.Scanner; 2 3 public class LabProgram { 4 5 6 7 8 9 10 11 12 13 14} public static void main(String[] args) { } Scanner scnr new Scanner(System.in); int size; size = scnr.nextInt(); int[] listA new int[size]; int[] listB new int[size]; here. */ = /* Type your code Develop mode Submit mode // List A // List B Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

How do i fix this code 

72344
21
22
25
}
=
0;
int sum
for(int i
0; i<len; i++) {
sum = sum + a[i] * b[i];
System.out.println(sum);
Develop mode Submit mode
=
Enter program input (optional)
123
321
Run program
=
Run your program as often as you'd like, before submitting for grading. Below, type any needed
input values in the first box, then click Run program and observe the program's output in the
second box.
Program errors displayed here
LabProgram.java:11: error: cannot find symbol
len =
sc.nextInt ();
Input (from above)
symbol: variable sc
location: class LabProgram
LabProgram.java:15: error: cannot find symbol
sc.nextInt ();
a[i]
=
symbol: variable sc
location: class LabProgram
LabProgram.java:18: error: cannot find symbol
b[i]
sc.nextInt ();
symbol: variable sc
location: class LabProgram
3 errors
LabProgram.java
(Your program)
Output (shown below)
Transcribed Image Text:72344 21 22 25 } = 0; int sum for(int i 0; i<len; i++) { sum = sum + a[i] * b[i]; System.out.println(sum); Develop mode Submit mode = Enter program input (optional) 123 321 Run program = Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. Program errors displayed here LabProgram.java:11: error: cannot find symbol len = sc.nextInt (); Input (from above) symbol: variable sc location: class LabProgram LabProgram.java:15: error: cannot find symbol sc.nextInt (); a[i] = symbol: variable sc location: class LabProgram LabProgram.java:18: error: cannot find symbol b[i] sc.nextInt (); symbol: variable sc location: class LabProgram 3 errors LabProgram.java (Your program) Output (shown below)
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning