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
(25 POINTS) Some applications work on all devices while others work on some devices. True or False?
scoray [572]

Answer:

True.

Explanation:

It is true that some applications work on some devices but not on others. This is so because it depends on the operating system of each device, that is, if the device has an operating system compatible with the application in question, said application will work, but if, on the contrary, the operating system is not compatible, the application will not be useful in this.

7 0
3 years ago
Explain the importance of determinism in an industrial LAN
nevsk [136]

Explanation:

 Determinism in an industrial local area network (LAN) basically improve the network and allow different types of technology use in various applications.

It basically refers to the network communication that uses various types of technology in the system like time scheduling to improve the deterministic real-time communication. It basically improve the transmission and provide ability to transfer data from one point to another.

The main importance of industrial LAN that it provide more flexible and efficient ethernet network in the system. It provide communication and interconnect various types of devices in the internet for efficient communication.

3 0
3 years ago
Jamie plans to sell his pottery designs through his website. If he also wants to launch a mobile app to reach more people, which
Liula [17]
He should launch an M-commerce app
5 0
2 years ago
Ms. Osteen gives her class an assignment to insert background color that gradually changes from blue to green. To accomplish thi
irina1246 [14]

Answer:

C

Explanation:

7 0
3 years ago
Kim agrees. You get the equipment from the truck and begin working. Kim approaches you as you are installing the modem and is a
Angelina_Jolie [31]
Ask your friends if they are doing something wrong with your friends and friends
6 0
1 year ago
Other questions:
  • A(n ____________ is considered a named collection of bytes having persistent or lasting storage.
    10·1 answer
  • Write an essay on online collaboration, how to do it, the challenges, resolving the challenges, and consider whether the risks a
    12·1 answer
  • Convert 578.2 into hexadecimal​
    13·1 answer
  • ________ is installed into special, read-only memory of devices like printers and print servers or devices used for various type
    13·1 answer
  • Tweaking existing technology in a new way is usually called _____. leveraged creativity state-of-the-art breakthrough applicatio
    5·1 answer
  • A(n) _________ is a computer system which is part of a larger system which performs a dedicated function.
    8·1 answer
  • What does it mean to say that data in an Excel table is “dynamically linked” to a chart? What are the advantages of this feature
    5·1 answer
  • List of rules for expert systems​
    6·1 answer
  • Hilarious error messages
    10·2 answers
  • ) Printers today have many features that include improved quality, photo printing capabilities, digital camera connectivity, bui
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!