What made these unique was the way you entered the


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

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: What made these unique was the way you entered the
Reference No:- TGS02700781

Expected delivery within 24 Hours