*The overall goal of the coursework is to investigate the use C++ templates to perform simple program generation tasks. *

Write C++ templates which allow you to use types to represent integer arithmetic expressions over the four basic operations (addition, subtraction, multiplication, integer division), a single variable, and integer literals, for instance

x + (x-2) * (x-3)

For the purposes of **Parts 1 and 2** we refer to the single variable as x.

The types representing the expressions should contain a function named ‘eval’ that provides code for evaluating the expression. This function should accept an integer parameter that will be used as the value for the single variable x.

Write a main() method that builds an expression as a type and evaluate it at some integer input value.

Print the results to standard out.

Extend your expression templates from Part 1 to allow each Expression type to carry with it a lower and upper bound for the possible values the expression could evaluate to. Of course, this depends on the range of values for the single variable x.

We will assume that the bounds on the input are statically known, and therefore you should parameterise the template type for representing the variable expressions on a type BOUNDS. The type BOUNDS itself should be a template parameterised on two integer values: the lower and upper values of the range for x.

Modify the eval function to throw an exception in case the input for x is not in the specified input range. Now modify your example in main() to build the expression based on a known range for the input values for x.

Print to standard out the calculated bounds for the output from the expression before printing the result of the evaluation.

For example, suppose that the bounds on variable x 0 <= x <= 5. Let us write this concisely as x_{0,5}.

Consider a sample expression with a variable that carries these bounds:

(x_{0,5} + 3) * ( x_{0,5} + 5)

Then we can calculate the bounds on the whole expression above as follows:

3 <= x_{0,5} + 3 <= 8 and 5 <= x_{0,5} + 5 <= 10

Consequently we have that

15 <= ( x_{0,5} + 3 ) * ( x_{0,5} + 5 ) <= 80

That is, the bounds for the above expression would be (15,80) if the bounds on x were (0,5).

Modify your expression templates from Part 2 to allow for multiple variables in the expression. Each occurrence of a variable expression can be considered as the unique variable named x, y, z,

... For example

x + (x-2) * (x-3) would be considered as x+ (y - 2) * (z - 3).

Modify the eval function to accept an array of integer values and evaluate each variable according to the corresponding position in the input array. For instance, in the above example variable z should evaluate to the 3rd value of the input array.

Note that each variable expression should be parameterised on a BOUNDS type so that there may be different bounds for each variable.

Modify your example in main() to provide a number of example input arrays and store the results of evaluation in an array called outputs.

Submission

Please submit well-documented C++ source code for each Part. That is, submit a zip archive with subdirectories called Part 1, Part 2, and Part 3. In each subdirectory have the relevant versions of the C++ templates, the example program requested and any other test programs you wish to show.

Assignment Writing Help

- Science Assignment Help
- Math Assignment Help
- Chemistry Assignment Help
- Physics Assignment Help
- Biology Assignment Help
- Psychology Assignment Help
- History Assignment Help
- Geography Assignment Help
- English Assignment Help
- Humanities Assignment Help
- Nursing Assignment Help
- Social Science Assignment Help
- Arts and Architecture Help
- Statistics Assignment Help
- Law Assignment Help
- Computational Mathematics Assignment Help

Engineering Assignment Services

- Programming Assignment Help
- Database Help
- Data Structure Assignment Help
- Operating Systems Assignment Help
- Computer Network Assignment Help
- UML Diagram Assignment Help
- IT Assignment Help
- Game Programming Help
- Computer Science Assignment Help
- Information Systems Assignment Help
- Chemical Engineering Assignment Help
- Civil Engineering Assignment Help
- Electrical, Electronics Help
- Mechanical Engineering Assignment Help
- Petroleum Engineering Assignment Help
- Biochemical and Biotechnology Help

Do My Assignment Help

- Accounting Assignment Help
- Finance Assignment Help
- Economics Assignment Help
- Marketing Assignment Help
- Human Resources Assignment Help
- Operations Management Assignment Help
- Strategy and Planning Help
- Project Management Help
- Case Studies Writing Help
- Political science
- Referencing Help
- Assignment Help Websites
- Online Assignment Help
- Do My Assignment
- Do My Homework

Write My Essay Services

- Essay Writing Help
- Business Essay Writing Help
- Assignment Writing Services
- Plagiarism Free Essay Writing
- Essay Editing Service
- Dissertation Writing Services
- Thesis Writing Help
- Custom Writing Help
- Write My Essay
- Write My Paper
- Paper Writing Service
- Academic Writing Help
- College Essay Writing
- Cheap Essay Writing