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
Which of the following are examples of IT careers? Check all of the boxes that apply.
krek1111 [17]

<u>Answer:</u>

  1. <em>software engineer </em>
  2. <em>hardware engineer </em>
  3. <em>systems analyst </em>
  4. <em>database administrator </em>
  5. <em>computer support specialist</em>

<u>Explanation:</u>

  • <em>Software engineer:</em> This deals with the application development where engineers develop application related to system software and application software which is used for commercial purposes.
  • <em>Hardware engineer:</em> Deals with problem in the hardware viz keyboard, mouse, mother board and other internal parts and also with network.
  • <em>Systems analyst: </em>This is once again a profession which deals with the internal problems of the system and also to install softwares and troubleshoot if issues arise.
  • <em>Database administrator: </em>Maintains the database, fix errors, monitor data, etc
  • <em>Computer support specialist:</em> The responsibility depends on the company and it will be similar to a clerical role.

Lawyer  This option is irrelevant

5 0
4 years ago
Read 2 more answers
State the steps for opening Ms word Application ​
Charra [1.4K]

Answer:

Step 1: From the desktop or from your 'Start' menu, open Microsoft Word. Step 2: Click either File or the Office button at the top left. Select Open and browse to the document you wish to open. Double-click on it with your left-hand mouse button to open it.

Explanation:

PLZ MARK AS THE BRAINLIEST

HAVE A GOOD DAY

: )

4 0
3 years ago
Which of the following tasks can you perform using a word processor?
frutty [35]

Answer:

check a document for spelling errors

Explanation:

With a word processor, you can easily edit and make changes to a document, move text around in a document, add images, change fonts, check for spelling errors

3 0
3 years ago
___ is the branch of computer science that explores techniques for incorporating aspects of intelligence into computer systems.
mamaluj [8]
Artificial Intelligence
5 0
3 years ago
project-1 Write a class called Person that has two data members - the person's name and age. It should have an init method that
MArishka [77]
Hello how are you today
4 0
3 years ago
Other questions:
  • The first thing to do when your computer gives you a error message is
    7·2 answers
  • What is the function of the Status bar in Outlook 2010?
    9·1 answer
  • In a PowerPoint presentation, it is not possible to add notes that are hidden from the audience's view.
    9·1 answer
  • Which programming language is good for 14 year old like me​
    12·2 answers
  • E-mail is an temporary message medium.<br> a. True<br> b. False
    5·2 answers
  • The ________ is responsible for the Internet's domain name system and the allocation of IP addresses.
    12·1 answer
  • Return a version of the given string, where for every star (*) in the string the star and the chars immediately to its left and
    5·1 answer
  • The NFiPA 704 system uses a numerical value between _____ and _____ to indicate the level of hazard for that particular chemical
    6·2 answers
  • What is analog computer?​
    14·1 answer
  • Display all the lines in unixPasswd that contain at least 10 consecutive lowercase letters. How many names are there in total th
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!