Answered step by step
Verified Expert Solution
Link Copied!

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:

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions

Question

using signal flow graph

Answered: 1 week ago