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

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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