Question: For this lab, we will review string manipulation. You will be writing a program which will prompt the user for a string in a specific

For this lab, we will review string manipulation. You will be writing a program which will prompt the user for a string in a specific format. You will then parse the input string and print it in a canonicalized format. The string is expected to consist three parts separated by semicolon. The first and the second parts will be both integer. The third part will be a string. The first and second parts represents the indexes of the first and last character of a substring that your program will extract from the third part and print the answer to the console. The input string format will be of the form ;; Your program must give an error message whenever a string is invalid. It should give a specific error message in the following three cases: - If a user enters an empty or just white spaces. - The first and the second parts are not valid range in the third part. - if the beginIndex is negative OR - endIndex is larger than the length of third part string, OR - beginIndex is larger than endIndex. - There are too many semicolons in the string(more than two). For this lab work, it is OK if your program crashes when calling Integer.parseInt and the argument is not a valid integer. You will need to use (at least) the indexOf (the overloaded version) and substring methods. Some sample inputs and their outputs are shown below. 8;26;send to office@hotmail.com please -> office@hotmail.com 0 ; 15; John@google.comta -> John@google.com -1 ; 17; John@google.comta -> Invalid Index! 5 ; 2; John@google.comta -> Invalid Index! 5 ; 50; John@google.comta -> Invalid Index!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!