Programiz Java Online Compiler Main.java 1- import java.util.Scanner; 2 import java.util.Random; // corrected: // removed 3 4 5- public class Main { 6 7 public static void main(String[] args) { //corrected: string() to string[] 9 Scanner input = new Scanner(System.in); 10 11 System.out.println("Enter a amount of times a pair of dice will roll: "); 12 int times-input.nextInt(); // corrected: keyboard to input 13 14 int[][] dicePairs = rollDicePairs(times); // corrected: int[] dicePairs to int[][] dicePairs System.out.println("The rolled pairs of numbers are: "); 15 printicePairs(dicePairs) Run Learn Java App Output Clear javac Itmp/EStonxIySG/Main.java /tmp/ES4onxIySG/Main.java:19: error: incompatible types: int[][] cannot be converted to int[] int[] dicePairSums = addDicePairs(dicePairs); //corrected: int[][] dicePairSums to int[] dicePairSums /tmp/ES4onxIySG/Main.java:20: error: cannot find symbol printDicePairsSum(dicePairs); // name of function is incorrect so changed method printDicePairsSum(int[][]) symbol location: class Main /tmp/ES4onxIySG/Main.java:59: error: incompatible types: int[] cannot be converted to int[][] return pairSums; 3 errors

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

WHAT IS WRONG WITH THE CODE??? HOW DO YOU SOLVE THESES ERRORS???

Online Java Compiler
0
To use dictation, go to Settings and turn on online speech recognition
с
programiz.com/java-programming/online-compiler/
Programiz Java Online Compiler
Learn Java App
Main.java
&
Run
Output
Clear
1- import java.util.Scanner;
♠ javac /tmp/ES4onxIySG/Main.java
2 import java.util. Random; // corrected: // removed
/tmp/ES4onxIySG/Main.java:19: error: incompatible types: int[][] cannot be converted to int[]
3
int[] dicePairSums = addDicePairs(dicePairs); //corrected: int[][] dicePairSums to int[] dicePairSums
^
4
5 public class Main {
/tmp/ES4onxIySG/Main.java:20: error: cannot find symbol
6
printDicePairsSum(dicePairs); // name of function is incorrect so changed.
7
public static void main(String[] args) { //corrected: string() to string[]
8
symbol: method printDicePairsSum(int[][])
9
Scanner input = new Scanner(System.in);
location: class Main
10
/tmp/ES4onxIySG/Main.java:59: error: incompatible types: int[] cannot be converted to int[][]
return pairSums;
11
System.out.println("Enter a amount of times a pair of dice will roll: ");
12
int times-input.nextInt (); // corrected: keyboard to input
13
3 errors
14
15
int[][] dicePairs = rollDicePairs (times); // corrected: int[] dicePairs to int[][] dicePairs
System.out.println("The rolled pairs of numbers are: ");
printDicePairs(dicePairs);
16
17
18
System.out.println("The sum of each pairs of numbers are: ");
19
int[] dicePairSums = addDicePairs(dicePairs); //corrected: int[][] dicePairSums to int[]
dicePairSums
20
printDicePairsSum(dicePairs); // name of function is incorrect so changed
21
22
}
23
24
//dicePairsSums -> dicepairSums
25
26
// name was given incorrectly
27
28
29
30
public static int[][] rollDicePairs(int times) { //public static double [] [] to public static int[][]
int[][] dice=new int[times] [2];
31
32
Random die=new Random();
33 ▾
for (int x=0; x<times; x++) {
34 ▾
for(int y=0; y<2; y++) {
35
dice[x][y] =1+die.nextInt (6);
36
HH
W
10
29°C Mostly clear
Type here to search
0;
x
ENG
9:54 pm
24/05/2022
:
1
Transcribed Image Text:Online Java Compiler 0 To use dictation, go to Settings and turn on online speech recognition с programiz.com/java-programming/online-compiler/ Programiz Java Online Compiler Learn Java App Main.java & Run Output Clear 1- import java.util.Scanner; ♠ javac /tmp/ES4onxIySG/Main.java 2 import java.util. Random; // corrected: // removed /tmp/ES4onxIySG/Main.java:19: error: incompatible types: int[][] cannot be converted to int[] 3 int[] dicePairSums = addDicePairs(dicePairs); //corrected: int[][] dicePairSums to int[] dicePairSums ^ 4 5 public class Main { /tmp/ES4onxIySG/Main.java:20: error: cannot find symbol 6 printDicePairsSum(dicePairs); // name of function is incorrect so changed. 7 public static void main(String[] args) { //corrected: string() to string[] 8 symbol: method printDicePairsSum(int[][]) 9 Scanner input = new Scanner(System.in); location: class Main 10 /tmp/ES4onxIySG/Main.java:59: error: incompatible types: int[] cannot be converted to int[][] return pairSums; 11 System.out.println("Enter a amount of times a pair of dice will roll: "); 12 int times-input.nextInt (); // corrected: keyboard to input 13 3 errors 14 15 int[][] dicePairs = rollDicePairs (times); // corrected: int[] dicePairs to int[][] dicePairs System.out.println("The rolled pairs of numbers are: "); printDicePairs(dicePairs); 16 17 18 System.out.println("The sum of each pairs of numbers are: "); 19 int[] dicePairSums = addDicePairs(dicePairs); //corrected: int[][] dicePairSums to int[] dicePairSums 20 printDicePairsSum(dicePairs); // name of function is incorrect so changed 21 22 } 23 24 //dicePairsSums -> dicepairSums 25 26 // name was given incorrectly 27 28 29 30 public static int[][] rollDicePairs(int times) { //public static double [] [] to public static int[][] int[][] dice=new int[times] [2]; 31 32 Random die=new Random(); 33 ▾ for (int x=0; x<times; x++) { 34 ▾ for(int y=0; y<2; y++) { 35 dice[x][y] =1+die.nextInt (6); 36 HH W 10 29°C Mostly clear Type here to search 0; x ENG 9:54 pm 24/05/2022 : 1
Online Java Compiler
с
programiz.com/java-programming/online-compiler/
Programiz Java Online Compiler
Main.java
33 ▾
for (int x=0; x<times; x++) {
34-
for (int y=0; y<2; y++) {
35
dice[x][y] =1+die.nextInt (6);
36
}
37
}
38
return dice;
39
}
40
41-
public static void printDicePairs (int[][] dicePairs){
42-
for (int[] pair: dicePairs) {
43-
for (int roll: pair) {
44
System.out.println(roll+" ");
45
}
46
System.out.println("");
47
}
48
}
49
50
public static int[][] addDicePairs(int [][] dicePairs){ // corrected: addDicePairs() to addDicePairs
(int[][] dicePairs)
51
int[] pairSums=new int[dicePairs.length];
52-
for (int x=0; x<pair Sums.length; x++) {
53
int sum=0;
54-
for(int y=0; y<dicePairs [x].length; y++) {
55
sum+=dicePairs [x][y];
56
}
57
pairSums [x]=sum;
58
}
59
return pairSums;
60
}
61
62-
public static void printDicePairs Sums (int[] dicePairSums) { //public static String to public static
void
63 -
for (int sum: dicePairSums) {
64
System.out.println(sum+" ");
65
}
66
67 }
W
10
}
Type here to search
O
0;
x
0
To use dictation, go to Settings and turn on online speech recognition
Learn Java App
G
Run
Output
Clear
• javac /tmp/ES4onxIySG/Main.java
/tmp/ES4onxIySG/Main.java:19: error: incompatible types: int[][] cannot be converted to int[]
int[] dicePairSums = addDicePairs(dicePairs); //corrected: int[][] dicePairSums to int[] dicePairSums
A
/tmp/ES4onxIySG/Main.java:20: error: cannot find symbol
printDicePairsSum(dicePairs); // name of function is incorrect so changed.
^
symbol: method printDicePairsSum(int[][])
location: class Main
/tmp/ES4onxIySG/Main.java:59: error: incompatible types: int[] cannot be converted to int[][]
return pairSums;
3 errors
29°C Mostly clear
ENG
9:54 pm
24/05/2022
:
1
Transcribed Image Text:Online Java Compiler с programiz.com/java-programming/online-compiler/ Programiz Java Online Compiler Main.java 33 ▾ for (int x=0; x<times; x++) { 34- for (int y=0; y<2; y++) { 35 dice[x][y] =1+die.nextInt (6); 36 } 37 } 38 return dice; 39 } 40 41- public static void printDicePairs (int[][] dicePairs){ 42- for (int[] pair: dicePairs) { 43- for (int roll: pair) { 44 System.out.println(roll+" "); 45 } 46 System.out.println(""); 47 } 48 } 49 50 public static int[][] addDicePairs(int [][] dicePairs){ // corrected: addDicePairs() to addDicePairs (int[][] dicePairs) 51 int[] pairSums=new int[dicePairs.length]; 52- for (int x=0; x<pair Sums.length; x++) { 53 int sum=0; 54- for(int y=0; y<dicePairs [x].length; y++) { 55 sum+=dicePairs [x][y]; 56 } 57 pairSums [x]=sum; 58 } 59 return pairSums; 60 } 61 62- public static void printDicePairs Sums (int[] dicePairSums) { //public static String to public static void 63 - for (int sum: dicePairSums) { 64 System.out.println(sum+" "); 65 } 66 67 } W 10 } Type here to search O 0; x 0 To use dictation, go to Settings and turn on online speech recognition Learn Java App G Run Output Clear • javac /tmp/ES4onxIySG/Main.java /tmp/ES4onxIySG/Main.java:19: error: incompatible types: int[][] cannot be converted to int[] int[] dicePairSums = addDicePairs(dicePairs); //corrected: int[][] dicePairSums to int[] dicePairSums A /tmp/ES4onxIySG/Main.java:20: error: cannot find symbol printDicePairsSum(dicePairs); // name of function is incorrect so changed. ^ symbol: method printDicePairsSum(int[][]) location: class Main /tmp/ES4onxIySG/Main.java:59: error: incompatible types: int[] cannot be converted to int[][] return pairSums; 3 errors 29°C Mostly clear ENG 9:54 pm 24/05/2022 : 1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Top down approach design
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education