Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Programming Project Assignment

1. Problem Statement:

In the 1970s Hewlett-Packard was famous for their hand held calculators. What made these unique was the way you entered the expressions using reverse Polish notation, where the operators came after the arguments. Instead of typing "2 + 3" you had to type "2 3 +". The reason for this bizarre notation was that expressions in this format can be easily evaluated using a stack. The numbers 2 and 3 are pushed on the stack, and when the "+" is entered, the top two values are popped off the stack, added together, and the result 5 pushed back on the stack and displayed. This can be used to calculate the values of more complicated expressions like "2 + 3 * 4". In this case, the user would type in "2 3 4 * +" and 14 would be displayed.

In this programming project, students will extend this idea of a stack-based calculator to evaluate Boolean expressions that use six C++ comparison operators (<, <=, >, >=, ==, !=) and two C++ logical operators (||, &&). When a user types in an integer value, it is pushed on the stack. When the user types in "true" or "false" it is pushed on the stack. Finally, when the user types in one of the comparison or logical operators above, the top two items are popped off the stack, the Boolean operation is performed, and the "true" or "false" result is pushed on the stack. When the user finishes typing in the Boolean expression, they type in a question mark character "?", and the program should evaluate the Boolean expression on the stack and print the top value on the stack. See the examples below:

Enter postfix Boolean expression: 1 10 < ? Result = true

Enter postfix Boolean expression: 1 10 < 2 5 > && ? Result = false

Your program should also include error checking and print an error message if the user enters anything that is incorrect. For example, if they type in "2 3 +" you should print "Error: unexpected operator +". Your program should also print out an error message if there is not enough data on the stack to perform an operation, or if there is extra data on the stack when the "?" is entered.

2. Design:

Obviously, you will need to use a stack to implement this program. Normally a stack contains only one type of data (integers, floats, strings). In this case, you need to store integer values and also Boolean true/false values. One way to do this is to store both data types as strings, and perform conversions as you evaluate the

Boolean expression. To do this, you will probably want to use the "atoi" function or the "stoi" function. Another option would be to store numbers and Boolean values on a stack of integers. In this case, the stack would store 1=true and 0=false.

Your second design task is to work out the main loop that reads user input, and either pushes it on the stack, or looks at the comparison operator to perform the required calculation. To start with, just work out how to deal with expressions of the form "2 5 >" and then work up to logical operations like "true false ||". When you have these going, you can test longer expressions like "1 10 < 2 5 > && ?".

3. Implementation:

There are two stack implementations on the class website that you can read and modify to store your Boolean expressions. There are also two programs that implement postfix calculators with numerical operators "+", "-", "*", "/" that you might want to look at. You can borrow and adapt any of the code on the class website that you need for this project.

As always, it is a good idea to work incrementally, writing comments, adding code, compiling, debugging, a little bit at a time. Remember to use good programming style when creating your program. Choose good names for variables and constants, use proper indenting for loops and conditionals, and type clear comments while you are writing the code. Also, be sure to save backup copies of your program somewhere safe. Otherwise, you may end up retyping your whole program if something goes wrong.

4. Testing:

Test your program to check that it operates correctly for all of the requirements listed above. Also check for the error handling capabilities of the code. Try your program with several input values, and save your testing output in text files for inclusion in your project report.

5. Documentation:

When you have completed your C++ program, write a short report using the project report template describing what the objectives were, what you did, and the status of the program. Does it work properly for all test cases? Are there any known problems? Save this report to be submitted electronically.

6. Midpoint Project Submission:

To encourage students to get an early start on their programming project, students are required to upload into Blackboard a partial solution to their programming project on the midpoint due date shown above. The program does not need to be complete, but it must compile and perform some of the tasks listed above. This midpoint solution is worth 10% of your final grade on the project.

7. Project Submission:

In this class, we will be using electronic project submission to make sure that all students hand their programming projects and labs on time, and to perform automatic plagiarism analysis of all programs that are submitted.

When you have completed the tasks above go to Blackboard to upload your documentation (a single docx or pdf file), and all of your C++ program files. Do NOT upload an executable version of your program.

The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit:

• 10% off if less than 1 day late,
• 20% off if less than 2 days late,
• 30% off if less than 3 days late,
• no credit if more than 3 days late.

You will receive partial credit for all programs that compile even if they do not meet all program requirements, so handing projects in on time is highly recommended.

8. Academic Honesty Statement:

Students are expected to submit their own work on all programming projects, unless group projects have been explicitly assigned. Students are NOT allowed to distribute code to each other, or copy code from another individual or website.

Students ARE allowed to use any materials on the class website, or in the textbook, or ask the instructor and/or GTAs for assistance.

This course will be using highly effective program comparison software to calculate the similarity of all programs to each other, and to homework assignments from previous semesters. Please do not be tempted to plagiarize from another student.

Violations of the policies above will be reported to the Provost's office and may result in a ZERO on the programming project, an F in the class, or suspension from the university, depending on the severity of the violation and any history of prior violations.

Attachment:- Code-Files.rar

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92743965

Have any Question?


Related Questions in Computer Engineering

Explain that this threat represents a well-known and broad

Explain that this threat represents a well-known and broad category of electronic and human activities that breach the confidentiality of information.

Under what circumstances is it ethical if ever to use

Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

What is the difference between dekkers algorithm and igloo

What is the difference between Dekkers Algorithm and Igloo approach? Please provide examples that can explain this.

Explain that when an unauthorized individual gains access

Explain that when an unauthorized individual gains access to the information an organization trying to protect, that act is categorized as a deliberate act of espionage or trespass.

Today is your 35th birthday and it occurs to you that your

Today is your 35th birthday and it occurs to you that your current retirement savings may be insufficient to maintain for you the lifestyle to which you have become accustomed. • The value of your retirement account toda ...

Question a student has a first name fname a last name lname

Question : A student has a first name (fname), a last name (lname), an identification number (id), a gender (male/female), a course name (cname) and the number of lectures (lcount) attended by the student. a. Define gend ...

Question i you are part of a disaster recovery team charged

Question: I. You are part of a disaster recovery team charged with completing the asset inventory at a small business that primarily sells a small selection of products to the public. 2. Establish a sample hardware asset ...

Taskstudents are required to do the following tasks for

Task Students are required to do the following tasks for write report by answering all the questions at the end of case study: Task a: Answering all the questions at the end of case study. Task b: Student is required to ...

A major airline company is concerned that its proportion of

A major airline company is concerned that it's proportion of late arrivals has substantially increased in the past month. Historical data shows that on the average 18% of the company airplanes have arrived late. And a ra ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As