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
As computer words get larger and larger, there is a law of diminishing returns: the speed of execution of real application progr
otez555 [7]

Answer:

Explanation:

I can pick a reason out of many, and that would be the software. The fact is that, even as they are computers and machines, the softwares themselves have particular design cap. A software that was designed for systems with a narrow word size will most likely have issues as more and more words are used on it. I don't know if you understand what I'm saying, everything has a cap, once that particular meter is approaching, systems tend to slow onwards.

When it comes to the hardware part using the same technology, it might take a longer time to do basic arithmetic on larger inputs.

When you're under using a system, it tends to have a lot of space, excess, to perform its functions, but as soon as it is nearing its limit, it will slow down so as to accommodate all the processes at once.

3 0
3 years ago
The chart shows an example of a study-time survey. Students can use the formula shown in the survey to figure out ways to track
LUCKY_DIMON [66]
<span>how many hours they can work on a project.</span>
3 0
4 years ago
Sketch f(x) = 5x2 - 20 labelling any intercepts.​
Norma-Jean [14]

Answer:

  • The graph of the function is attached below.
  • The x-intercepts will be: (2, 0), (-2, 0)
  • The y-intercept will be: (-20, 0)

Explanation:

Given the function

f\left(x\right)\:=\:5x^2-\:20

As we know that the x-intercept(s) can be obtained by setting the value y=0

so

y=\:5x^2-\:20

switching sides

5x^2-20=0

Add 20 to both sides

5x^2-20+20=0+20

5x^2=20

Dividing both sides by 5

\frac{5x^2}{5}=\frac{20}{5}

x^2=4

\mathrm{For\:}x^2=f\left(a\right)\mathrm{\:the\:solutions\:are\:}x=\sqrt{f\left(a\right)},\:\:-\sqrt{f\left(a\right)}

x=\sqrt{4},\:x=-\sqrt{4}

x=2,\:x=-2

so the x-intercepts will be: (2, 0), (-2, 0)

we also know that the y-intercept(s) can obtained by setting the value x=0

so

y=\:5(0)^2-\:20

y=0-20

y=-20

so the y-intercept will be: (-20, 0)

From the attached figure, all the intercepts are labeled.

8 0
3 years ago
What is the BCC feature used for?
exis [7]

Answer:

to send an email to someone without revealing that person’s email address to others on the distribution list

Explanation:

BAM

7 0
3 years ago
Read 2 more answers
Which model is the oldest and most common technique of differentiating information systems?
steposvetlana [31]
The answer to this question is Pyramid model. In pyramid mode, all information systems will be divided into different classes that will form a hierarchy and usually it is based on importance. The most important aspects will be placed on the top of the pyramid structure while the least important aspects will be placed on the very bottom.
8 0
3 years ago
Read 2 more answers
Other questions:
  • In the two-level directory, if a user refers to a particular file then__________________ Select one: a. only his/her own UFD (us
    7·1 answer
  • What is the only real language a computer understands?
    8·1 answer
  • What is the purpose of the operating systems processor management function
    7·1 answer
  • Write a statement that declares an int variable named count.
    9·1 answer
  • The partners of a small architectural firm are constantly busy with evolving client requirements. To meet the needs of their cli
    11·1 answer
  • Cross-functional systems are being phased out in favor of systems that support business processes within a single functional gro
    14·1 answer
  • A ________ is a term used to describe a select list that allows the user to select an option to load another web page.
    10·1 answer
  • Write a program that will sort an array of data using the following guidelines - DO NOT USE VECTORS, COLLECTIONS, SETS or any ot
    10·1 answer
  • Pleaseeeeeeee tellllllllllllllllllllll​
    8·1 answer
  • Which feature is used to help identify the appropriate content for particular form fields?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!