Check10E (TS = 35)

Download the jar file typex.jar (the file has been updated on December 4, 19:00) and save it in the same directory as type.jar. typex.jar should already be part of your CLASSPATH.

Create the program named Check11E that prompts the user by printing

Enter a word and a positive integer.
The integer should be smaller than the length of the word.
The word and the integer should be separated by one or more spaces.
The user should provide the input on the next line.

If the user only enters a single word then the app should print


Not enough tokens.
Please try again.

Enter a word and a positive integer.
The integer should be smaller than the length of the word.
The word and the integer should be separated by one or more spaces.
The user should provide the input on the next line. Note that there is an empty line between the input provided by the user and the feedback.

If the user enters a word followed by something that is not an integer then the app should print


Not an integer.
Please try again.

Enter a word and a positive integer.
The integer should be smaller than the length of the word.
The word and the integer should be separated by one or more spaces.
The user should provide the input on the next line. Note that there is an empty line between the input provided by the user and the feedback.

If the user enters a word followed by an integer which is smaller than 0 or greater than or equal to the length of the word then the app should print


Invalid index.
Please try again.

Enter a word and a positive integer.
The integer should be smaller than the length of the word.
The word and the integer should be separated by one or more spaces.
The user should provide the input on the next line. Note that there is an empty line between the input provided by the user and the feedback.

If the user enters a word followed by an integer which is greater than or equal to 0 and smaller than the length of the word then the app should terminate after printing

The i-th character of the word "w" is c
where w is the word entered by the user, i is the integer entered by the user, and c is the i-th character of the word (if the user enters the integer 1, then the first character is printed).

Challenge: try not to use conditionals, that is, try to avoid using if statements, switch statements and the ternary operator . ? . : .

To check whether your code is correct, you can use eCheck. You are advised to use the offline mode first. Once your code is correct (worth 3 marks) and you are happy with your style (worth 2 marks), you can switch to the online mode and submit your solution. For style, you should adhere to the code conventions described in Appendix C of the textbook.