Question: 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

I need this code to be split up into two different classes.

/* 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

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!