Compulsory Task Follow these steps: ● For this task, you are required to refactor the badly written program RPN.java. This program is a Reverse-Polish Notation calculator which uses a stack. A Reverse-Polish Notation calculator is a calculator that will calculate equations where the operator follows the operands. Therefore, instead of inputting an equation as “1 + 2”, a Reverse-Polish Notation calculator would take the following input “ 1 2 +”. A stack is a data structure in which items are added to the top of the stack and removed from the top of the stack. It is therefore known as a last-in, first-out (LIFO) data structure. Stack terminology: ○ Push — is an operation that adds an item to the top of a stack. ○ Pop — is an

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 9E
icon
Related questions
Question
Compulsory Task Follow these steps: ● For this task, you are required to refactor the badly written program RPN.java. This program is a Reverse-Polish Notation calculator which uses a stack. A Reverse-Polish Notation calculator is a calculator that will calculate equations where the operator follows the operands. Therefore, instead of inputting an equation as “1 + 2”, a Reverse-Polish Notation calculator would take the following input “ 1 2 +”. A stack is a data structure in which items are added to the top of the stack and removed from the top of the stack. It is therefore known as a last-in, first-out (LIFO) data structure. Stack terminology: ○ Push — is an operation that adds an item to the top of a stack. ○ Pop — is an operation that removes an item from the top of a stack. The pseudocode for this program is: ○ Get an equation (e.g. 2 3 +) from the user as input. ○ Loop through the string value input by the user. ■ When you encounter a number (remember that numbers can include decimal points), add it to the stack (push). ■ When you encounter an operator (e.g. +, -, /, etc.), pop two numbers from the stack and perform the appropriate calculation. ○ Display the answer of the calculation to the user. ● For this task you are required to: ○ Troubleshoot and debug the code so that it runs correctly. ○ Fix the indentation and formatting of the code so that it adheres to the guidelines provided here. ○ Make sure that all the names of variables, classes, methods, etc. adhere to the guidelines provided here. ○ Refactor the code to improve the quality and readability of the code in other ways highlighted in this task. ○ Most students who have to resubmit this Task do so due to errors and styling issues. To help you discover errors and styling issues quicker (before submitting your Task), please install the linter, SonarLint, to your IDE or editor. Use SonarLint to identify problems and clear each one of them until there are no issues being flagged. By default, it’s configured to flag issues based on the best practices we’ve discussed in this review.
SE L2T16 - Object-Oriented Desic X
← →
I
G Google
SE L2T20 - Refactoring
New Tab
Type here to search
CV/N ✪ File C:/Users/Dell/Dropbox/DT20070002991/2-%20Introduction%20to%20Software%20Engineering/L2T20/SE%20L2T20%20-%20Refactoring.pdf Q
Addons Store AliExpress B. Booking.com f Facebook ►YouTube
X
O
SE L2T20 - Refactoring
6:
12 / 13
Compulsory Task
X +
67% + A
Follow these steps:
• For this task, you are required to refactor the badly written program
RPN.java. This program is a Reverse-Polish Notation calculator which
uses a stack.
A Reverse-Polish Notation calculator is a calculator that will calculate
equations where the operator follows the operands. Therefore, instead of
inputting an equation as "1+2", a Reverse-Polish Notation calculator
would take the following input *12+".
A stack is a data structure in which items are added to the
top of the stack and removed from the top of the stack. It is
therefore known as a last-in, first-out (LIFO) data structure.
Stack terminology.
o Push - is an operation that adds an item to the top
of a stack.
o Pop - is an operation that removes an item from the top of a stack.
The pseudocode for this program is:
o Get an equation (e.g. 23 +) from the user as input.
o
• For this task you are required to:
Loop through the string value input by the user.
■ When you encounter a number (remember that numbers
can include decimal points), add it to the stack (push).
■ When you encounter an operator (e.g. +, -, /, etc.), pop two
numbers from the stack and perform the appropriate
calculation.
o Display the answer of the calculation to the user.
o Troubleshoot and debug the code so that it runs correctly.
O
88
14°C
℗ I
4)
19:11
11/30/2022
⠀
X
:
Transcribed Image Text:SE L2T16 - Object-Oriented Desic X ← → I G Google SE L2T20 - Refactoring New Tab Type here to search CV/N ✪ File C:/Users/Dell/Dropbox/DT20070002991/2-%20Introduction%20to%20Software%20Engineering/L2T20/SE%20L2T20%20-%20Refactoring.pdf Q Addons Store AliExpress B. Booking.com f Facebook ►YouTube X O SE L2T20 - Refactoring 6: 12 / 13 Compulsory Task X + 67% + A Follow these steps: • For this task, you are required to refactor the badly written program RPN.java. This program is a Reverse-Polish Notation calculator which uses a stack. A Reverse-Polish Notation calculator is a calculator that will calculate equations where the operator follows the operands. Therefore, instead of inputting an equation as "1+2", a Reverse-Polish Notation calculator would take the following input *12+". A stack is a data structure in which items are added to the top of the stack and removed from the top of the stack. It is therefore known as a last-in, first-out (LIFO) data structure. Stack terminology. o Push - is an operation that adds an item to the top of a stack. o Pop - is an operation that removes an item from the top of a stack. The pseudocode for this program is: o Get an equation (e.g. 23 +) from the user as input. o • For this task you are required to: Loop through the string value input by the user. ■ When you encounter a number (remember that numbers can include decimal points), add it to the stack (push). ■ When you encounter an operator (e.g. +, -, /, etc.), pop two numbers from the stack and perform the appropriate calculation. o Display the answer of the calculation to the user. o Troubleshoot and debug the code so that it runs correctly. O 88 14°C ℗ I 4) 19:11 11/30/2022 ⠀ X :
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,