mirror of
https://github.com/System-End/APCSA.git
synced 2026-04-19 23:32:54 +00:00
23 lines
732 B
Java
23 lines
732 B
Java
import java.util.Scanner;
|
|
|
|
public class U2_L4_Activity_One {
|
|
|
|
public static void main(String[] args) {
|
|
Scanner scanner = new Scanner(System.in);
|
|
|
|
// get first string
|
|
System.out.println("Enter first string");
|
|
String s1 = scanner.nextLine();
|
|
|
|
// get second string
|
|
System.out.println("Enter second string");
|
|
String s2 = scanner.nextLine();
|
|
|
|
//Get number of letters to use from each string
|
|
System.out.println("Enter number of letters from each word");
|
|
int n = scanner.nextInt();
|
|
|
|
// print last n letters of first string combined with first n letters of s2
|
|
System.out.println(s1.substring(s1.length() - n) + s2.substring(0, n));
|
|
}
|
|
}
|