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
Jake was working on an essay for his English class on a stormy Sunday afternoon. Before he could save his document, a big strike
matrenka [14]

Maybe in atosave, Computers mostly save what your working on :3

8 0
3 years ago
The chip that controls the radio frequency waves within a device
torisob [31]

Answer:

An RF module

Explanation:

I googled it lol

7 0
3 years ago
TRUE OR FALSE - SQL language is used to query data in a Relational Database?
Gelneren [198K]

Answer:

Yes I agree with the other person who answered that

5 0
2 years ago
Sharing a workbook enables multiple users to access the workbook. What are the benefits of using a shared workbook?
damaskus [11]

Answer:

Some of the benefits of sharing a workbook include:

A. Shared information between students (ie: Mary writes a note about (blank) in the workbook and John reads said note and receives addition information about (blank)).

B. ^adding onto this, discussion on interpretations of a passage (ie: John thinks (blank) means this and Mary thinks (blank) means other thing, through notes they can discuss the meaning of the text.

Hope this helps. =)

8 0
3 years ago
98 points possible
joja [24]

A programming language is not used to talk from human to human. It is used to talk from a human to a computer. Computers are very dumb compared to us, so they need to be taught or spoken to in simple terms. Asking them something complex is far beyond their understanding, as they cannot learn anything beyond what has already been taught to them. Using print: “Hello, World” is the way to tell them to do stuff way less complex than when we say ‘write the words Hello, World on the screen’. A programming language is also not very easy to create. Talking to a computer in a dumb way reduces the process to make a new language for the computer to understand.

6 0
3 years ago
Read 2 more answers
Other questions:
  • A program to add two numbers in C++
    15·1 answer
  • What is Blender's default save directory for movie AVI files?
    9·2 answers
  • A slideshow that accompanies an oral report is known as what?
    6·1 answer
  • ___ is an example of a function prototype.
    12·1 answer
  • 27. If X and Y are int type variables,
    14·1 answer
  • Whats the formatting of a letter to the editor?​
    12·1 answer
  • Write an application that inputs a five digit integer (The number must be entered only as ONE input) and separates the number in
    10·1 answer
  • Jonathan is in the process of creating a photo of a fluttering flag with cars moving around in the background. He wants the flag
    13·2 answers
  • What is the first phone ever made?
    6·1 answer
  • Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!