Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need this code to be split up into two different classes. One class is the driver that will exicute the code. the other will

I need this code to be split up into two different classes. One class is the driver that will exicute the code. the other will contain the methods to do the calculations. current output is correct just all in one file

image text in transcribed

/* postfix2infix/Postfix2infix.java */ package postfix2infix;

import postfix2infix.LinkedStack; import java.io.*;

public class Postfix2infix { public static void main(String [] arg) { BufferedReader input = new BufferedReader (new InputStreamReader(System.in));

String choice = new String("Y");

do { try { System.out.println("Enter a postfix expression:"); String infixStr = input.readLine();

String [] elements = infixStr.split("\\s+"); // split around series of whitespaces

LinkedStack stack = new LinkedStack();

for(int i = 0; i

//top of stack contains the infix expression, stack should be of size 1 if(stack.size() == 1) { System.out.println("In Infix Notation: " + stack.pop()); } else { System.out.println("Malformed post fix expression"); } } catch (Exception e) { e.printStackTrace(); }

System.out.print("Translate another expression [Y/N]? "); try { choice = input.readLine(); } catch (Exception e) { e.printStackTrace(); } } while(choice.compareToIgnoreCase("Y") == 0); } }

umairaz@umairaz:-/CHEGGS javac postfix2infix/Linkedstack.java umairazumairaz:~/CHEGGS javac postfix2infix/Postfix2infix.java umairaz@umairaz:~/CHEGGS java postfix2infix.Postfix2infix Enter a postfix expression: 3 4 2 In Infix Notation: ((3 + 4)* 2) Translate another expression [Y/N]? y Enter a postfix expression: 4 23 51-*+ In Infix Notation: ((4 + 2) + (3 *(5 - 1))) Translate another expression [Y/N]? n umairaz@umairaz:-/CHEGGS

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

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 2 Lncs 8056

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013th Edition

3642401724, 978-3642401725

More Books

Students also viewed these Databases questions

Question

What is the principle of thermodynamics? Explain with examples

Answered: 1 week ago

Question

Explain the strength of acid and alkali solutions with examples

Answered: 1 week ago

Question

state what is meant by the term performance management

Answered: 1 week ago