Find Jobs
Hire Freelancers

algorithms 2nd year coursework

$10-15 USD

Cancelled
Posted over 17 years ago

$10-15 USD

Paid on delivery
very basic question, anyone who has any programing experience should be able to complete this in about 15 mins r probably less!! ## Deliverables **Modify the PostFixEvaluator program to use a ListStack and then evaluate the expression:** ** 3 4 * 2 5 + - 4 * 2 /** ** Explain in words the behaviour of the program.** Shown below is the code that i was provided with in order to start the question //******************************************************************** // [login to view URL] Authors: Lewis/Chase // // Represents an evaluator of postfix expressions. Assumes the // operands are constants. //********************************************************************import [login to view URL]; import [login to view URL];public class PostfixEvaluator { private final char ADD = '+', SUBTRACT = '-'; private final char MULTIPLY = '*', DIVIDE = '/'; private ArrayStack stack; //----------------------------------------------------------------- // Sets up this evalutor by creating a new stack. //----------------------------------------------------------------- public PostfixEvaluator() { stack = new ArrayStack(); } //----------------------------------------------------------------- // Evaluates the specified postfix expression. //----------------------------------------------------------------- public int evaluate (String expr) { int op1, op2, result = 0; String token; StringTokenizer tokenizer = new StringTokenizer (expr); while ([login to view URL]()) { token = [login to view URL](); if (isOperator(token)) { op2 = ((Integer)[login to view URL]()).intValue(); op1 = ((Integer)[login to view URL]()).intValue(); result = evalSingleOp ([login to view URL](0), op1, op2); [login to view URL] (new Integer(result)); } else [login to view URL] (new Integer([login to view URL](token))); } return result; } // Determines if the specified token is an operator. private boolean isOperator (String token) { return ( [login to view URL]("+") || [login to view URL]("-") || [login to view URL]("*") || [login to view URL]("/") ); } // Evaluates a single expression consisting of the specified // operator and operands. private int evalSingleOp (char operation, int op1, int op2) { int result = 0; switch (operation) { case ADD: result = op1 + op2; break; case SUBTRACT: result = op1 - op2; break; case MULTIPLY: result = op1 * op2; break; case DIVIDE: result = op1 / op2; } return result; } } ## Platform not entirely sure but i would think that it would in most versions of windows. the program itself has to run on a program called "J Creator"
Project ID: 3939979

About the project

Remote project
Active 17 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs

About the client

Flag of IRELAND
Ireland
0.5
1
Member since Nov 27, 2006

Client Verification

Other jobs from this client

programming code
$10-15 USD
Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.