Design pre-post conditions for required operations

Assignment Help Programming Languages
Reference no: EM131321205

Assignment Programming Project: Expression Trees

This project deals with a simple kind of expression trees, in which there are two kinds of nodes:

(a) Leaf nodes, which contain a real number as their clement; and

(b) Non-leaf nodes, which have exactly two children and contain one of these characters as their element: +, -, * and /. These characters represent arithmetic operations and have usual interpretations.

Implement a class for expression trees with these operations:

(a) A constructor that builds an expression tree. It accepts a String that represents a rammatically correct expression as its sole input. Hint: refer to a previous assignment on evaluating expressions.

(b) A recursive method named eval that evaluates a non-empty expression tree using these rules:

i. If the tree has only one node (which must be a leaf), then eval returns the real number that is the node's clement;

ii. If the tree has more than one node and the root contains op where op is one of +, -, * and /, then eval first evaluates the sub trees of the root and returns the real number obtained by performing operation op on the results from evaluating the sub-trees.

(c) A recursive method named infix that output the expression represented by a non-empty expression tree to a String in infix format.

(d) A recursive method named postfix that outputs the expression represented by a non-empty expression tree in postfix format.

You also need to write another class that applies the operations of the above class.

Please submit

1. Analysis: test data;

2. Design:

- A class invariant for each class;
- Pre/Post conditions for required operations;
- Algorithms for required operations.

3. Code;

4. Screen snapshots of test runs.

Reference no: EM131321205

Questions Cloud

Conservation of momentum for an inelastic collision : A 34kg cannonball is fired at dimitri who weighs 136 kg. if the cannonball is fired with an initial velocity of 8.9m/s with what speed does the combination of dimitri and the cannonball tumble backwards? Use conservation of momentum for an inelast..
What are a linear relationship and curvilinear relationship : When are correlational research designs used in behavioral research? What are their advantages and disadvantages?
What are the partners respective shares of the bank loan : A, B and C are the members of All, LLC, a limited liability company that is treated as a partnership for federal income tax purposes. If the requested indemnities are given, what are the partners' respective shares of the bank loan allocated to th..
Prepare a balance sheet as of december 31 : 1. Prepare an income statement for the year ended December 31 - Prepare a statement of owner's equity for the year ended December 31. No additional investments were made during the year and Prepare a balance sheet as of December 31.
Design pre-post conditions for required operations : Design Pre/Post conditions for required operations; A recursive method named postfix that outputs the expression represented by a non-empty expression tree in postfix format.
How many electron hole pairs are generated per unit : Verify that the photon energy Is 2.25eV. How many electron-hole pairs are generated per unit volume per second in each crystal?
Why does the tilt of the earth cause the seasons : Why does the tilt of the Earth cause the seasons? It seems to me like the distance from the Earth to the Sun should cause the seasons.
What is a spurious relationship : In what ways can correlational data provide information about the likely causal relationships among variables?
What is the purpose of random assignment to conditions : In what ways are experimental research designs preferable to correlational or descriptive designs? What are the limitations of experimental designs?

Reviews

Write a Review

Programming Languages Questions & Answers

  Program to calculate overtime pay for salary based employee

To calculate overtime pay for a salary based employee, first find hourly rate by dividing gross pay by 40, and then calculate overtime pay.

  Program that uses a recursive function to print a string

Your program must contain a recursive function that prints the string backwards. Do not use any global variables; use appropriate parameters.

  Develop the flow diagram

Develop the flow diagram of the information and any control elements needed to ensure proper access for the information.Submit a draft PowerPoint presentation with the following elements

  Create three exception classes named numberhighexception

Create three exception classes named NumberHighException, NumberLowException, and NumberNegativeException. Both NumberHighException and NumberLowException should be directly subclassed from the Exception class

  Design and implement a stringed musical instrument class

Design and implement a Java program that will gather integer numbers and performs some computations on the data entered. The program should use separate methods for inputting the data, calculating the sum, calculating the average, calculating the ..

  Implement a program to learn vocabulary of foreign languages

We want to implement a program which will help students learn the vocabulary of foreign languages. The first step, which has been assigned to you, is to build a data structure representing a list of English words and their translation in a foreign..

  Analysis the advantages and disadvantages of social network

Analyze how the university might integrate at least two social media and networking technologies to accomplish their goals. Your analysis must cover the advantages and disadvantages of social networking.

  How many constraints variables does the sub problem have

How many constraints and decision variables does the sub problem have? Formulate a dynamic-programmig model to solve this sub problem, assuming that b1 = 1. Show that this solution determines a ray of the sub problem.

  Object-oriented analysis and design

Object-Oriented Analysis and Design,  PART B-object-oriented design involves the steps 13-18:

  Wysiwyg editors can be used to learn html

What about fact that WYSIWYG editors can be utilized to learn HTML? As you can usually jump back and forth from their own image.

  Wap to accept four numbers andcompute

Q. WAP to accept four numbers andcompute their sum,per,grade and average.

  Javascript program that will read a message string

Write a JavaScript program that will read a message string and a number from text boxes on a Web page. The program will then use those values to display some information to the user.

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