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 02:00
Aisha has finished working on a word processing document that contains 15 pages. she has added some special elements in the first three pages, page 9 and 10, and page 15 from the document. she wants to print only these pages to see how they look. which option is the correct way to represent (in the print dialog box) the pages that aisha wants to print?
Answers: 1
question
Computers and Technology, 23.06.2019 05:00
In cell b18, enter a formula to calculate the amount budgeted for meals. this amount is based on the daily meal allowance and the total travel days (# of nights+1).
Answers: 1
question
Computers and Technology, 23.06.2019 09:50
Allison and her group have completed the data entry for their spreadsheet project. they are in the process of formatting the data to make it easier to read and understand. the title is located in cell a5. the group has decided to merge cells a3: a7 to attempt to center the title over the data. after the merge, allison points out that it is not centered and looks bad. where would the title appear if allison unmerged the cells in an attempt to fix the title problem?
Answers: 2
question
Computers and Technology, 23.06.2019 18:30
Report all segments of identity by descent longer than 20 polymorphisms between pairs of individuals in the following cohort of 15 individuals across 49 polymorphisms: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 numeric input 2 points possible (graded) you have 2 attempts to complete the assignment below. for example if the sequence is "bcd", which occurs in "abcdef" , the starting point would be 2 (b), and the finishing point would be 4(d). individuals 7,10 between positions
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
Health, 16.12.2020 20:10
question
History, 16.12.2020 20:10
question
Business, 16.12.2020 20:10
question
English, 16.12.2020 20:10
question
Mathematics, 16.12.2020 20:10
question
History, 16.12.2020 20:10
Questions on the website: 13722363