Question: Using Stack to solve problems in javascript 1) Design and Implement a Java program that reads a sentence from the user and prints the sentence

Using Stack to solve problems

in javascript

1) Design and Implement a Java program that reads a sentence from the user and prints the sentence with the characters of each word backwards. Use the ArrayStack in part 1 to reverse the characters of each word. A sample output is shown in Figure 1. Note that different sentence will be used for grading. It is required that the ArrayStack class should be utilized in solving this problem.

Using Stack to solve problems in javascript 1) Design and Implement a

2) Implement a postfix-to-infix translator using stacks. Postfix notation1[1] is a notation for writing arithmetic expressions in which the operands appear before their operators. There are no precedence rules to learn, and parentheses are never needed. Because of this simplicity, some popular hand-held calculators use postfix notation to avoid the complications of the multiple parentheses required in nontrivial infix expressions. We have discussed how these postfix expressions can be evaluated using a stack in class. You are then to write a Java program to translate a postfix notation to infix notation. A sample output is shown in Figure 2, and some postfix expressions are given in as below for testing purpose. Note that different postfix notations will be used for grading. It is required that the LinkedStack class in part 1 should be utilized in solving this problem.

Java program that reads a sentence from the user and prints the

run: Enter a sentence: Hello nice to meet you in CS102 Reversing each word: ollet ecin ot teem uoy ni 2015C BUILD SUCCESSFUL (total time: 14 seconds) Figure 1: reverse character run: Enter a postfix expression: 3 4 + 2 * In Infix Notation: ((3 - 4) * 2) Translate another expression (Y/N]? Y Enter a postfix expression: 4 2 - 3 5 1 - * - In Infix Notation: ((4 + 2) + (3 (5 - 1))) Translate another expression (Y/N)? Figure 2: postfix-to-infix translator Some Postfix For Testing 45 72 +-*-16 - 3 4 + 2 * 7/2+ 5 7 + 6 2 - * 48 - 42 351-+* + 18 * 42 + 351 - * + 18 / run: Enter a sentence: Hello nice to meet you in CS102 Reversing each word: ollet ecin ot teem uoy ni 2015C BUILD SUCCESSFUL (total time: 14 seconds) Figure 1: reverse character run: Enter a postfix expression: 3 4 + 2 * In Infix Notation: ((3 - 4) * 2) Translate another expression (Y/N]? Y Enter a postfix expression: 4 2 - 3 5 1 - * - In Infix Notation: ((4 + 2) + (3 (5 - 1))) Translate another expression (Y/N)? Figure 2: postfix-to-infix translator Some Postfix For Testing 45 72 +-*-16 - 3 4 + 2 * 7/2+ 5 7 + 6 2 - * 48 - 42 351-+* + 18 * 42 + 351 - * + 18 /

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!