1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
telo118 [61]
3 years ago
6

1. Print out the string length of s1 2. Loop through characters in s2 with charAt() and display reversed string 3. Compare s2, s

3 with compareTo(), print out which string (s2 or s3) is greater than which string (s2 or s3), or equal, print the result out 4. Use the regionMatches to compare s2 and s3 with case sensitivity of the first 8 characters and print out the result (match or not) . 5. Find the location of the first character 'g' in s1, print it out 6. Find the last location of the substring "class" from s2, print it out
Computers and Technology
1 answer:
konstantin123 [22]3 years ago
7 0

Answer:

See explaination

Explanation:

public class StringLab9 {

public static void main(String args[]) {

char charArray[] = { 'C', 'O', 'S', 'C', ' ', '3', '3', '1', '7', ' ', 'O', 'O', ' ', 'C', 'l', 'a', 's', 's' };

String s1 = new String("Objected oriented programming language!");

String s2 = "COSC 3317 OO class class";

String s3 = new String(charArray);

// To do 1: print out the string length of s1

System.out.println(s1.length());

// To do 2: loop through characters in s2 with charAt and display reversed

// string

for (int i = s2.length() - 1; i >= 0; --i)

System.out.print(s2.charAt(i));

System.out.println();

// To do 3: compare s2, s3 with compareTo(), print out which string (s2 or s3)

// is

// greater than which string (s2 or s3), or equal, print the result out

if (s2.compareTo(s3) == 0)

System.out.println("They are equal");

else if (s2.compareTo(s3) > 0)

System.out.println("s2 is greater");

else

System.out.println("s3 is greater");

// To do 4: Use the regionMatches to compare s2 and s3 with case sensitivity of

// the first 8 characters.

// and print out the result (match or not) .

if (s2.substring(0, 8).compareTo(s3.substring(0, 8)) == 0)

System.out.println("They matched");

else

System.out.println("They DONT match");

// To do 5: Find the location of the first character 'g' in s1, print it out

int i;

for (i = 0; i < s2.length(); ++i)

if(s2.charAt(i)=='g')

break;

System.out.println("'g' is present at index " + i);

// To do 6: Find the last location of the substring "class" from s2, print it

// out

int index = 0, ans = 0;

String test = s2;

while (index != -1) {

ans = ans + index;

index = test.indexOf("class");

test = test.substring(index + 1, test.length());

}

System.out.println("Last location of class in s2 is: " + (ans + 1));

// To do 7: Extract a substring from index 4 up to, but not including 8 from

// s3, print it out

System.out.println(s3.substring(4, 8));

} // end main

} // end class StringLab9

You might be interested in
Need help with this please
Rasek [7]

Answer:

4. let eggs = 5

let bread = 10

let soda = 6

5.

let total = eggs+bread+soda

4 0
3 years ago
An I/O-bound process ___________________________________________________ Select one: a. does not need CPU time b. spends less of
DiKsa [7]

Answer:

Spends more of its time seeking I/O operations than doing computational work.

Explanation:

The I/O bound process are depend on Input and output speed. on the other hand computational work is associated with CPU bound processes. Therefore option "C" is better option for I/O bound processes.

8 0
4 years ago
What is output by the following code? for x in range(7, 16): print(x * 2, end=" ") Group of answer choices 14 16 18 20 22 24 26
madreJ [45]

Input:-

\tt for\:x\:in\:range(7,16):

\tt print(x*2,end"")

Output:-

\tt 14,16,18,22,24,26,28,30,32

The loop will start from 7×2=14 to 16×2=32

8 0
3 years ago
Research the difference between the heart and the brain ???? and say which is most important and why????​
antoniya [11.8K]

Answer:

The brain is more important because the heart would not be able to function without instructions from the brain, which is very important. The brain is what gives orders to the rest of the body to keep everything going.

Sorry if my explanation sounds bad, I'm not great at wording things))

6 0
3 years ago
Deonte, an engineer, has designed a specialized bicycle tire for a manufacturer. What industry does Dante work in?
yawa3891 [41]

Answer:

i think its number 4, because its only the tire itself

Explanation:

7 0
3 years ago
Other questions:
  • Which view is used to allow a publisher to view facing pages of a publication at the same time?  NormalMaster PageTwo-Page Sprea
    9·1 answer
  • Which function is used to display a string value to the screen?
    8·1 answer
  • What is the line tool used for in photoshop
    6·1 answer
  • One part of a development team has completed an algorithm. Why is it important to share it with others on the team? Choose all t
    15·1 answer
  • The four smallest numbers (40 points) Write an ANNA assembly program (smallest_four.ac) that finds the four smallest numbers ent
    11·1 answer
  • Can someone help me calculate this Multimedia math:
    11·1 answer
  • Write a program that uses a stack to test input strings to determine whether they are palindromes. A palindrome is a sequence of
    7·1 answer
  • if you are trying to reduce the cost of college, which of the following strategies is likely to save you the most money?
    9·1 answer
  • Write a function called changeCharacter that takes three parameters – a character array, its size, and the replacement character
    15·1 answer
  • What type of programing code do game developers use.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!