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
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 22PE
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb4d4e6a3-fd83-4270-b000-89a89a72868b%2F083d839d-65c2-4a13-91b1-707e2105e135%2Fgte4sa5i_processed.png&w=3840&q=75)
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb4d4e6a3-fd83-4270-b000-89a89a72868b%2F083d839d-65c2-4a13-91b1-707e2105e135%2Fhsavsrx_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
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)](https://content.bartleby.com/qna-images/question/b4d4e6a3-fd83-4270-b000-89a89a72868b/1658a838-e7b3-4106-b7ec-a9279b37b905/xkbk0xb_thumbnail.png)
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
Knowledge Booster
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.Recommended textbooks for you
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr