1. a. Correct the following code so that it generates 50 random integers in the range of 30 up to and including 110 and stores the numbers in array r. Correct all errors. Int (]r= new int(49]; for (int i=0; kr.length+1;1+{ ri) = 10+Math.randomo*100; b. The following code checks if two characters next to each other in a String str are the same. If a match is found, It prints a message as shown below. Find all errors and correct them so the output for the String str in the example is 7 has a match I has a match String str = "ghu7763459823||"; for (int l=1; Ie=str.length()-1; -) { If (str.charAt(l-1) = str.charAt(1)) System.out.printin(str.charAt(i-1)+" has a match");

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question
100%
1. a. Correct the following code so that it generates 50 random integers in the range of 30 up to and
including 110 and stores the numbers in array r. Correct all errors.
int []r= new int[49];
for (int i=0; Ikr.length+1;1++){
rij = 10+Math.random0*i00;
b. The following code checks if two characters next to each other in a String str are the same. If a
match is found, it prints a message as shown below. Find all errors and correct them so the output
for the String str in the example is
7 has a match
į has a match
String str = "ghu7763459823jj";
for (int i=1; Ie=str.length()-1; -)
{ if (str.charAt(i-1) == str.charAt(1))
System.out.printlin(str.charAt(i-1)+" has a match");
Transcribed Image Text:1. a. Correct the following code so that it generates 50 random integers in the range of 30 up to and including 110 and stores the numbers in array r. Correct all errors. int []r= new int[49]; for (int i=0; Ikr.length+1;1++){ rij = 10+Math.random0*i00; b. The following code checks if two characters next to each other in a String str are the same. If a match is found, it prints a message as shown below. Find all errors and correct them so the output for the String str in the example is 7 has a match į has a match String str = "ghu7763459823jj"; for (int i=1; Ie=str.length()-1; -) { if (str.charAt(i-1) == str.charAt(1)) System.out.printlin(str.charAt(i-1)+" has a match");
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Program on Numbers
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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage