Consider you are given a very specialized string with a
unique format
as:
Quiz_(no) # (q.no) : (question statement) $ (option1) , (option 2) , … * (right option number) … \n
String starts with Quiz_ (quiz number like 1, 2, … ), then hash #, then question number (like qno_1, qno_2 …), then colon :, then question statement, then dollar $, then options (like option1, option 2 …), then asterisk *, and then right option for the given question statement. If more questions are there for the same quiz, then pattern after hash # is repeated (means every question is separated by # symbole). Each quiz ends with new line (\n), and then new quiz starts with same pattern as before. A sample pattern is given below.
Quiz_1# qno_1: What comes next to First $first, second, third, fourth *2 # qno_2: What comes before second $first, second, third, fourth, fifth *1 \nQuiz_2# qno_1: What is liquid $water, bread, smoke *1 # qno_3: What is hot $ice-cream, candies, spices *3
You are required to create a program in JAVA, in such a way that if your program
receives any string with this pattern
(or format) it should
provide output as given below. (Hint: Use split, trim method to do the job)
Extracted text: Quiz_1 qno_1;What comes next to First 1. frist 2. second 3. third 4. fourth tight option is 2 qno_2;Wbat comes before second 1. first 2. second 3. third 4. fourth 5. fifth tight option is 1 Quiz_2 qno_1:What is liquid 1. water 2. bread 3. smoke right option is 1 qno_3;What is hot 1. icecream 2. candies. 3. spices tight option is 3