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");

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 11PE
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
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT