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
On the Direct Marketing worksheet, create appropriate range names for Design Fee (cell B8), Cost Per Ad (cell B9), Total Clicks
Inessa [10]

Answer:

See explanation below

Explanation:

Named ranges are a very important tool in Microsoft Excel. It is used in assigning a name to a particular number of cells. It is great for automation and makes formula much easy to understand and use.

One way to create named ranges is theory the Name Box.

To create named ranges in the design marketing sheet we do this;

1) We click on cell B8 and then navigate to the name box at the top right corner of the sheet just above the column A.

•The name box is where the cell address of any cell that is active is displayed.

•You would see that “B8” is displayed on the name box.

• Double click on the name box and type in the appropriate name, in this case - Design_Fee.

• Press enter and you have your named range.

You do the same for the other named ranges.

Note that: Named ranges must contain letters, numbers or underscore.

4 0
3 years ago
When you first open a word processor, you’ll find a ? document. A. filled B. blank C. edited
NikAS [45]
B, blank document is the answer
3 0
3 years ago
Read 2 more answers
What is the purpose of a mail merge field?
Alex73 [517]

Answer:

to set up placeholders in a document where data will be inserted

4 0
3 years ago
Read 2 more answers
What is the Difference between CUI and GUI
Fynjy0 [20]

Hi there!


GUI Means Graphical user interface


CUI means  Controlled Unclassified Information


Theres the difference they are completely different from each other.


PLEASE MARK BRAINLIEST

-WeasuLL

7 0
3 years ago
Read 2 more answers
Who designed the Analytical Engine in the 1830s? Alan Turing Alan Turing Charles Babbage Charles Babbage Bill Gates Bill Gates S
Dmitriy789 [7]
Charles Babbage Charles Babbage
7 0
2 years ago
Other questions:
  • On what dates did the 2016 Olympics take place( list all)
    9·2 answers
  • Which wireless device does the manager most likely have before being offered the upgrade by her supervisor?
    8·2 answers
  • If you are viewing a webpage with customized or regenerated content, such as updated stock quotes, what type of webpage are you
    14·1 answer
  • Displays are geared for a specific resolution. what is this resolution called?
    15·1 answer
  • Which of the following is the component of the processor that directs and coordinates most of the operations in the computer?A.
    12·1 answer
  • Thomas drew a rectangle with an area of 6 square cm what is the greatest possible perimeter of this rectangle
    5·1 answer
  • Differentiate Between register and Memory location (
    13·1 answer
  • Ayudaa, 5 ejes de sistemas tecnológicos
    5·1 answer
  • Can someone please help me to point out what's wrong with this C program:
    13·1 answer
  • What is software engineering? What are the objectives of software engineering?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!