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

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

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 ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

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

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 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