Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some help with this question in java: You may assume the user will enter a one line properly formatted post fixed math expression,

I need some help with this question in java:

You may assume the user will enter a one line properly formatted post fixed math expression, with the tokens (operators and operands) separated by white space. You should use the API Stack class and the StringTokenizer class. Declare your Stack object to be a stack that can only store objects in the class Double.

Below is an outline of the program.

import java.util.*; // needed for the StringTokenizer class

import javax.swing.*;

// Declare a Java API Stack object that can store Double objects (See page 168)

// Accept the users input of the math String into the variable mathExpression

// Evaluate the math expression[1] // see the code template in Exercise 21, page 171

// Pop the stack and output the returned value

[1] Be sure to parse the numeric operands to doubles before pushing them onto the stack

below is the code template given in excercise 21, page 171:

import java.util;

String thisToken;

StringTokenizer tokens = new StringTokenizer(mathExpression);

while(tokens.hasMoreTokens())

{ thisToken = tokens.nextToken();

// processing for thisToken goes here

}

Thank you any help is appreacted.

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 22nd International Conference Dexa 2011 Toulouse France August/September 2011 Proceedings Part 1 Lncs 6860

Authors: Abdelkader Hameurlain ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2011th Edition

3642230873, 978-3642230875

More Books

Students also viewed these Databases questions