Where the operators came after the arguments

Assignment Help Computer Engineering
Reference no: EM131905295

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

Reference no: EM131905295

Questions Cloud

Pound at expiration : What will your profit or loss be if coffee prices turn out to be $2.0108 per pound at expiration?
What is the total cost for one contract : How much does your option cost per bushel of corn? What is the total cost for one contract? Assume each contract is for 5,000 bushels.
Were management decisions to stay competitive sound : Were management's decisions to stay competitive sound? What course of action do you recommend for the management of Green Pastures?
Commercial banks are primary source of debt capital : In the US, commercial banks are the primary source of debt capital for existing (not new) businesses?
Where the operators came after the arguments : What made these unique was the way you entered the expressions using reverse Polish notation, where the operators came after the arguments.
What historical data might beuseful : Team B found 184 errors. What metricswould you propose to help in making the determination? What historical data might beuseful?
The property for purposes of calculating any gain would be : If Ragan should now sell the home for $500,000, his basis in the property for purposes of calculating any gain would be:
What is the appropriate rate for use in discounting the free : The acquisition would be made immediately, if it is to be undertaken. Sally's pre-merger beta is 2.0, and its post-merger tax rate would be 34%.
Discuss how wireframe displays might be generated : Discuss how wireframe displays might be generated with the various visible-surface detection methods discussed in this chapter.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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