Write a program to evaluate an arithmetic expression

Assignment Help C/C++ Programming
Reference no: EM132106278

Program : Restricted Structures

Write a program to evaluate an arithmetic expression written in postfixed notation. The arithmetic expression will be input as a String (by the user) and will contain only integer operands. Use the following code sequence to parse (i.e., remove) the integers and the ioerators from the input string, mathExpression:

import java.util;

String thisToken;

StringTokenizer tokens = new StringTokenizer(mathExpression);

while(tokens.hasMoreTokens())

{ this token = tokens.nextToken();

//proccessing for thisToken goes here

}

You may assume the user will enter a one line properly formatted post fixed mathexpression, 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 user's input of the math String into the variable mathExpression

// Evaluate the math expression //

// Pop the stack and output the returned value

(Be sure to parse the numeric operands to doubles before pushing them onto the stack)

Reference no: EM132106278

Questions Cloud

Characteristics on international marketing opportunities : MGT107 - International Marketing - Bachelor of Applied Management - Southern Institute of Technology - Compare and contrast the impact of geographic
Write a program that simulates the heap using a linked list : Write a program that simulates the "heap" using a linked list. This program should start off by taking one node of size 9096 KB.
Types of resources on the web : What types of resources on the web would work best for a visual learner and how would a visual learner use that type of resource as a student.
What is heutagogical learning : What is heutagogical learning? What are the similarities and differences between heutagogy and widely-known concepts of self-directed
Write a program to evaluate an arithmetic expression : Write a program to evaluate an arithmetic expression written in postfixed notation. The arithmetic expression will be input as a String.
Display the sorted list to the monitor : Your program should then sort the integers from small-est to largest using an if-else chain and then display the sorted list to the monitor.
What is a nonequivalent control group pretest-posttest : What is a nonequivalent control group pretest-posttest design study involving diet and weight loss?
How to the operating systems schedule all the processes : You need to populate multiple processes. The processes should be managed by your system from the viewpoint of the Operating Systems.
Residents of assisted care facilities : A researcher is investigating the effects of life review group therapy on depression among elderly residents of assisted care facilities.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd