Question: Write in Java: 1. As a programmer one must know whether sequences of parentheses are properly ordered. For example, one knows that (())()

Write in Java:

Write in Java: 1. As a programmer one must know whether sequences

1. As a programmer one must know whether sequences of parentheses are properly ordered. For example, one knows that " (())() " is properly ordered; however, ")()(" is not. But what if instead of parentheses, we use letters. If we have letters, then one needs to know what characters match one another. For this problem it's just going to be the character on the opposite half of the alphabet. For example, A and Z match, B and Y match, C and X match, and so on, until you see that M and N match. Furthermore, they can match forward and backward. This means that "AZ" and "ZA" are properly ordered sequences of letters. And for a more complicated example, "ZNMA" would also match. Write a program to check to see if letters match based on the algorithm mentioned above. Input from the keyboard a string of uppercase letters. Output to the screen "YES" if the string of letters is properly ordered; otherwise print "NO". 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. Sample Run: Enter the string: CCXX YES Run again (Y/N):Y Enter the string: ABCDZYXW No

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!