Code: //I have choosen a scenario of my shopping where I went to buy a T-Shirt import java.util.*; import java.io.*; class Test{ public static void main (String[] args){ Scanner input = new Scanner(System.in); System.out.print(\"Enter the amount You have: \"); String str = input.nextLine(); String[] strl = str.split(\" \"); int strlen = strl.length; if (strlen == 1){ System.out.println(\"First word: \"+strl[0]); }else if (strlen == 2){ System.out.println(\"First word: \"+strl[0]); System.out.println(\"Second word: \"+strl[1]); }else if (strlen == 3){ System.out.println(\"First word: \"+strl[0]); System.out.println(\"Second word: \"+strl[1]); System.out.println(\"Third word: \"+strl[2]); }else if (strlen == 4){ System.out.println(\"First word: \"+strl[0]); System.out.println(\"Second word: \"+strl[1]); System.out.println(\"Third word: \"+strl[2]); System.out.println(\"Fourth word: \"+strl[3]); }else{ System.out.println(\"First word: \"+strl[0]); System.out.println(\"Second word: \"+strl[1]); System.out.println(\"Third word: \"+strl[2]); System.out.println(\"Fourth word: \"+strl[3]); System.out.println(\"Fourth word: \"+strl[4]); } System.out.println(\"\ Middle 10 characters: \"+ str.substring(0,10)); } } Output: Enter the amount You have: Hello my name is computer science 1001 First word: Hello Second word: my Third word: name Fourth word: is Fourth word: computer Middle 10 characters: is compute Solution Code: //I have choosen a scenario of my shopping where I went to buy a T-Shirt import java.util.*; import java.io.*; class Test{ public static void main (String[] args){ Scanner input = new Scanner(System.in); System.out.print(\"Enter the amount You have: \"); String str = input.nextLine(); String[] strl = str.split(\" \"); int strlen = strl.length; if (strlen == 1){ System.out.println(\"First word: \"+strl[0]); }else if (strlen == 2){ System.out.println(\"First word: \"+strl[0]); System.out.println(\"Second word: \"+strl[1]); }else if (strlen == 3){ System.out.println(\"First word: \"+strl[0]); System.out.println(\"Second word: \"+strl[1]); System.out.println(\"Third word: \"+strl[2]); }else if (strlen == 4){ System.out.println(\"First word: \"+strl[0]); System.out.println(\"Second word: \"+strl[1]); System.out.println(\"Third word: \"+strl[2]); System.out.println(\"Fourth word: \"+strl[3]); }else{ System.out.println(\"First word: \"+strl[0]); System.out.println(\"Second word: \"+strl[1]); System.out.println(\"Third word: \"+strl[2]); System.out.println(\"Fourth word: \"+strl[3]); System.out.println(\"Fourth word: \"+strl[4]); } System.out.println(\"\ Middle 10 characters: \"+ str.substring(0,10)); } } Output: Enter the amount You have: Hello my name is computer science 1001 First word: Hello Second word: my Third word: name Fourth word: is Fourth word: computer Middle 10 characters: is compute.