Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment4: Evaluate Arithmetic Expressions. Requirements: Implement a concrete ArrayStack class that extends the IStack interface as we discussed in the class (any other different Stack

Assignment4: Evaluate Arithmetic Expressions.

Requirements:

  1. Implement a concrete ArrayStack class that extends the IStack interface as we discussed in the class (any other different Stack class implementation, even if it is implemented by yourself, will not receive any credit).
  2. Write a test class called Evaluate and a method that evaluates an arithmatic expression, which is given by a string.
import java.util.Scanner; public class Evaluate { public static void main(String[] args) } // your implementation // obtain user's input from keyboard // invoke method expression() to get the result and print it out } public static int expression(String str) { // return the value } } 

public interface IStack {

abstract public int size();

//returns size of stack abstract public Object top();

//returns top of stack abstract public Object pop();

//removes top of stack and returns value abstract public void push(Object x) throws FullStackException;

//inserts data object to top of stack abstract public boolean isEmpty();

//returns true or false if stack is empty

}

  1. Your implementation is required to use the IStack interface we discussed in the class.
  2. provide a necessary test case to verify the result. For example,
    14-3*4+2*5-6*2 (should return 0) 
    In another example,
    14-3*(4+2*(5-6))*2 (should return 2) 
    You may want to test all possible corner conditions to make sure your implement is inclusive.
  3. Your implementation only considers +, - and * operators, as well as the parentheses (), and does not need to consider other operators and brackets. In particular, your code should not work with division operator "/".

Grading Criteria:

  • Please make sure your program compiles, otherwise your submission will not be graded and you will receive zero.
  • Point deduction rule:
    1. Compile warning: 3 points each.
    2. Minor error: such as not meeting the assignment input/output requirement, 5 points each.
    3. Major error: examples include, infinite loop, runtime errors, any runtime exception, 15 points each.
    4. Any code not compliant to the assignment requirement (e.g., not using IStack interface or ever using generic programming) will not be graded and you will receve zero.
    5. 20 point penalty if your program works with division operator "/".
  • (40%) Correct implementation of IStack.java, ArrayStack.java and StackFullException.java.
  • (40%) Correct implementation of Evaluate class with the expression method that correctly evaluates the expression with +, - and * operators.
  • (10%) The above expression method supports the parentheses ().
  • (10%) Correct README file (with the required contents).

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

Mastering Apache Cassandra 3 X An Expert Guide To Improving Database Scalability And Availability Without Compromising Performance

Authors: Aaron Ploetz ,Tejaswi Malepati ,Nishant Neeraj

3rd Edition

1789131499, 978-1789131499

More Books

Students also viewed these Databases questions

Question

Compute the derivative f(x)=1/ax+bx

Answered: 1 week ago

Question

What is job enlargement ?

Answered: 1 week ago

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago