Find Jobs
Hire Freelancers

algorithms 2nd year coursework

$10-15 USD

Скасований
Опублікований over 17 years ago

$10-15 USD

Оплачується при отриманні
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"
ID проекту: 3939979

Про проект

Дистанційний проект
Активність 17 yrs ago

Хочете заробити?

Переваги подання заявок на Freelancer

Вкажіть свій бюджет та терміни
Отримайте гроші за свою роботу
Опишіть свою пропозицію
Реєстрація та подання заявок у проекти є безкоштовними

Про клієнта

Прапор IRELAND
Ireland
0,5
1
На сайті з лист. 27, 2006

Верифікація клієнта

Інші роботи від цього клієнта

programming code
$10-15 USD
Дякуємо! Ми надіслали на вашу електронну пошту посилання для отримання безкоштовного кредиту.
Під час надсилання електронного листа сталася помилка. Будь ласка, спробуйте ще раз.
Зареєстрованих користувачів Загальна кількість опублікованих робіт
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Завантажуємо для перегляду
Дозвіл на визначення геолокації надано.
Ваш сеанс входу закінчився, і сеанс було закрито. Будь ласка, увійдіть знову.