diff --git a/U2/L3/U2_L3_Activity_Four.java b/U2/L3/U2_L3_Activity_Four.java new file mode 100644 index 0000000..68666b3 --- /dev/null +++ b/U2/L3/U2_L3_Activity_Four.java @@ -0,0 +1,13 @@ +/* Lesson 3 Coding Activity Question 4 */ + +import java.util.Scanner; + +public class U2_L3_Activity_Four { + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + System.out.println("Enter a sentence"); + String sentence = scan.nextLine(); + System.out.println(sentence.indexOf(" ")); + } +} diff --git a/U2/L3/U2_L3_Activity_One.java b/U2/L3/U2_L3_Activity_One.java new file mode 100644 index 0000000..8bc436d --- /dev/null +++ b/U2/L3/U2_L3_Activity_One.java @@ -0,0 +1,17 @@ +/* Lesson 3 Coding Activity Question 1 */ + +import java.util.Scanner; + +public class U2_L3_Activity_One { + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + System.out.println("Enter a string:"); + String item = scan.nextLine(); + System.out.println("Enter a number:"); + int n = scan.nextInt(); + System.out.println( + item.substring(0, n) + item.substring(item.length() - n) + ); + } +} diff --git a/U2/L3/U2_L3_Activity_Three.java b/U2/L3/U2_L3_Activity_Three.java new file mode 100644 index 0000000..0fbacdc --- /dev/null +++ b/U2/L3/U2_L3_Activity_Three.java @@ -0,0 +1,15 @@ +/* Lesson 3 Coding Activity Question 3 */ + +import java.util.Scanner; + +public class U2_L3_Activity_Three { + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + System.out.println("Enter first word:"); + String one = scan.nextLine().toLowerCase(); + System.out.println("Enter second word:"); + String two = scan.nextLine().toLowerCase(); + System.out.println("Result: " + one.compareTo(two)); + } +} diff --git a/U2/L3/U2_L3_Activity_Two.java b/U2/L3/U2_L3_Activity_Two.java new file mode 100644 index 0000000..01042d5 --- /dev/null +++ b/U2/L3/U2_L3_Activity_Two.java @@ -0,0 +1,17 @@ +/* Lesson 3 Coding Activity Question 2 */ + +import java.util.Scanner; + +public class U2_L3_Activity_Two { + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + System.out.println("Enter a string:"); + String word = scan.nextLine(); + System.out.println( + "How many characters would you like to delete at the end?" + ); + int del = scan.nextInt(); + System.out.println(word.substring(0, word.length() - del)); + } +}