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
skad [1K]
3 years ago
8

1. Write a program that uses String method regionMatches to compare two strings input by the user. The program should prompt the

user to enter two strings, the starting index in the first string, the starting index in the second string, and the number of characters to be compared. The program should print whether or not the strings are equal. (Ignore the case of the characters during comparison.) This is a sample run of your program: Enter·first·string:Have·yourself·a·merry·little·Christmas.↵ Enter·second·string:It's·beginning·to·look·a·lot·like·christmas.↵ Enter·starting·index·for·first·string:29·↵ Enter·starting·index·for·second·string:34·↵ Enter·number·of·characters·to·be·compared:9↵ true↵
Computers and Technology
1 answer:
likoan [24]3 years ago
8 0

Answer:

  1. import java.util.Scanner;
  2. public class Main {
  3.    public static void main(String[] args) {
  4.        Scanner input = new Scanner(System.in);
  5.        System.out.print("Input first string: ");
  6.        String string1 = input.nextLine();
  7.        System.out.print("Input second string: ");
  8.        String string2 = input.nextLine();
  9.        System.out.print("Start index for first string: ");
  10.        int i1 = input.nextInt();
  11.        System.out.print("Start index for second string: ");
  12.        int i2 = input.nextInt();
  13.        System.out.print("Number of characters to be compared: ");
  14.        int n = input.nextInt();
  15.        if(string1.regionMatches(true, i1, string2, i2, n)){
  16.            System.out.println("The strings are equal.");
  17.        }
  18.        else{
  19.            System.out.println("The strings are not equal.");
  20.        }
  21.    }
  22. }

Explanation:

The solution code is written in Java.

Firstly create a Scanner object (Line 5).

Next, use the Scanner object and nextLine method to get user input for  string1 and string 2 (Line 7 - 11 )

Next, proceed to get the start index for first and second string using nextInt (Line 14 and Line 17) and followed with number of characters to be compared (Line 20).

Use the regionMatches method by passing all the input values as argument (Line 22) and if we pass the sample input we shall get the true and the program shall display the message "The strings are equal." (Line 22- 23)

You might be interested in
All presentations should have this. A. a clear central message. B. a design template. C. at least seven slides. D. special effec
Oksi-84 [34.3K]

Answer:

A. a clear central message.

When creating a presentation on basically anything, there should always be a clear central message. The purpose of most presentations are to give information on what the presenter would like to convey to the audience members. Without a clear central message, the audience members would be lost and the presentations purpose will not be fulfilled.

4 0
3 years ago
Read 2 more answers
To open computer manger you would
Irina18 [472]
"start", "control panel", "administrative tools", "computer management" thats it
8 0
3 years ago
Engineers use science to ______ things that people use.
jek_recluse [69]

Answer:

Not 100% sure but I think it is either to solve things that people use or improve things that people use

Explanation:

8 0
3 years ago
Intel Centrino Technology is the combinatin of wirelesstechnology with the previous HT technology.
Kay [80]

Answer:

<u>False</u>

Explanation:

Great question, it is always good to ask away and get rid of any doubts that you may be having.

The Intel Centrino Technology is a product marketed and sold by the tech giant Intel, which offers a combination of their Wi-Fi and WiMax technologies in a single personal laptop. It does not offer Hyper threading Technology (HT) like some of the other Intel branded CPU's. Some of the CPU's that include hyper threading are the Core I3 series.

Therefore, based on the information stated above, we can see that the statement in the question in <u>False</u>.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

7 0
3 years ago
What is the one common feature that ties together different social media technologies? All of the social media tools we use toda
xxTIMURxx [149]
They provide an intersection between technology, social interaction, and the sharing of information
8 0
3 years ago
Read 2 more answers
Other questions:
  • In three or four sentences, describe how a person buys and sells stock.
    6·2 answers
  • When computers connect to one another to share information, but are not dependent on each other to work, they are connected thro
    7·1 answer
  • (GAME DESIGN)
    15·1 answer
  • Patrick Stafford's article argues that the growth of mobile phone usage "has given developers the ability to great robust and en
    7·1 answer
  • What is a close-up shot, and when it is an appropriate shot choice in a film?
    6·1 answer
  • When Twitter is used to gather a large group for a face-to-face meeting it is called a
    10·1 answer
  • Error: 404 Not Found <br>The resource that you requested does not exist on this server.
    14·2 answers
  • You should structure the first before you search for a relevant picture.
    8·1 answer
  • Name the written test a potential driver must pass and list the minimum required score to earn a learner’s license.
    8·2 answers
  • Gn guys have an Amazing day!
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!