subject

In this exercise you will debug the code which has been provided in the starter file. The code is intended to take two strings, s1 and s2 followed by a whole number, n, as inputs from the user, then print a string made up of the first n letters of s1 and the last n letters of s2. Your job is to fix the errors in the code so it performs as expected (see the sample run for an example). Sample run
Enter first string
sausage
Enter second string
races
Enter number of letters from each word
3
sauces
Note: you are not expected to make your code work when n is bigger than the length of either string.
1 import java. util. Scanner;
2
3 public class 02_14_Activity_one {
4 public static void main(String[] args) {
5
6 Scanner scan = Scanner(System. in);
7
8 //Get first string
9 System. out. println("Enter first string");
10 String s1 = nextLine(); 1
11
12 //Get second string
13 System. out. println("Enter second string");
14 String s2 = Scanner. nextLine();
15
16 //Get number of letters to use from each string
17 System. out. println("Enter number of letters from each word");
18 String n = scan. nextLine();
19
20 //Print start of first string and end of second string
21 System. out. println(s1.substring(1,n-1) + s2.substring(s1.length()-n));
22
23
24 }

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:30
Today is the anniversary of me being on yet, i don't need it anymore! here's a picture of my dog wearing a bowtie! my question is, how do i delete my account?
Answers: 1
question
Computers and Technology, 22.06.2019 15:00
Which of the following has not been attributed at least in part to social media a. drug addiction b. depression c. kidnapping d. murder
Answers: 2
question
Computers and Technology, 22.06.2019 21:30
Elements such as fonts colors visual structure graphics and the interface of a web page should complement each other to ensure blank
Answers: 3
question
Computers and Technology, 23.06.2019 14:00
How are stop motion special effects in animated films created
Answers: 1
You know the right answer?
In this exercise you will debug the code which has been provided in the starter file. The code is in...
Questions
question
English, 24.10.2020 08:10
question
Biology, 24.10.2020 08:10
question
English, 24.10.2020 08:10
question
Mathematics, 24.10.2020 08:10
question
Mathematics, 24.10.2020 08:10
question
Mathematics, 24.10.2020 08:10