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)
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)
Step by step
Solved in 4 steps with 1 images