Answer:
- import java.util.Scanner;
-
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
-
- System.out.print("Input first string: ");
- String string1 = input.nextLine();
-
- System.out.print("Input second string: ");
- String string2 = input.nextLine();
-
- System.out.print("Start index for first string: ");
- int i1 = input.nextInt();
-
- System.out.print("Start index for second string: ");
- int i2 = input.nextInt();
-
- System.out.print("Number of characters to be compared: ");
- int n = input.nextInt();
-
- if(string1.regionMatches(true, i1, string2, i2, n)){
- System.out.println("The strings are equal.");
- }
- else{
- System.out.println("The strings are not equal.");
- }
- }
- }
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)
// Variable to keep track of array size
int length = 0;
// Array itself
int array[] = {};
// while loop will take input in the array until a negative number is entered
while(input>=0){
stdin = new Scanner(System.in);
array[length] = stdin;
length +=1;
}
// int variable to terminate while loop
int i =0;
// keep track of index of output array
int y =0;
while(arr[i] != length){
// making output array
int output[]={}; bool flag;
// put the element in out put array considering if it the desired one
output[y] = array [i];
// Now check if it was the desired?
for(int z=1;z<=length;z++){
if(array[i+z]!=output[y]){
flag = true;
}
else
{
output[y]=0;
y+=1;
}
if(array[i+z+1]=output[y] && flag == true){
output[y] = array[i];
y+=1;
}
}
//output the array
for(int o=0;o<y;o++)
System.out.println(output[o];
Answer:
I'm not sure if you can pick inbetween, but that's what I'm doing.
I believe that technology is both good and bad for society. Before technology and social media, things were much simpler. there was no cyber bullying, there were no eye problems due to phone and computer screens, insomnia was less common, and people spent more personal time together. But, with access to technology, you can easily contact family members or 9-1-1 in case of emergencies, you can stay up to date on news, you can keep yourself entertained for extended amounts of time, you can talk to new people every day, and you can find information in seconds.
so, in conclusion, there are good and bad things about technology.
No, interior lighting makes less visibility for drivers. It becomes harder to see out the window.