Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write in Java: 3. Given a string of parentheses, write a program that uses the vertical bar ( ') and underscore ( ' ') characters
Write in Java:
3. Given a string of parentheses, write a program that uses the vertical bar ( ') and underscore ( ' ') characters to connect the matching parentheses. Input from the keyboard a string with at most 30 characters and contains only the open and close parentheses and spaces. Assume there will be at least one parenthesis in each input string. Output to the screen the string with exactly one space between parentheses. If there are any mismatched parentheses in the string, print the message "Parentheses do not match!" Otherwise, use the vertical bar and underscore characters to draw lines between matching parentheses. Each line must be at least one vertical bar in depth, but no line should be deeper than it needs to be. Follow the format illustrated in sample output below. The program must use a stack data structure. Finally, the program should ask if the user wants to run the program again (Check case). Refer to the sample output below
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started