Answered step by step
Verified Expert Solution
Question
1 Approved Answer
the user is asking missing code. just have to complete the methods. Source History package calcrpn; 3 o import java.util.Stack; 4 public class CalcBrain implements
the user is asking missing code. just have to complete the methods.
Source History package calcrpn; 3 o import java.util.Stack; 4 public class CalcBrain implements CalcRPNOperations 7 a Stack Float> results; String operand; 8 9 Cener.java 10 public CalcBrain() { results - new StacksFloat> (); operand - 12 13 14 The digit method takes the digit input parameter and appends it to the operand variable. Then the method returns the digit. Compile and run the application. Confirm by clicking on each number 0 through 9 appears in the text area. The clearEntry method resets the operand back to the empty string. Return the string that is shown when you run the CalcRPN jar application and perform the same action. The addDecimal method adds a decimal point to the operand. Then it returns the period character. This method needs to be handled carefully because only one decimal is allowed in an operand. Use the String method contains to help you here. The enterPressed method pushes a non-blank operand (converted to a Float) onto the results Stack. (If the operand is blank, simply return a blank string). You can use Float parseFloat to convert a String object to a Float object. The operand must be reset to an empty string. You can return a single space The clear method clears the results Stack and the operand. The operator method performs the calculation work as determined by the type of operator it is passed. First the method pushes the operand value onto the results Stack if that operand is non-blank (and then resets operand blank). Then the method returns an empty string if the results Stack has less than two elements in it use the Stack's size method) because there is no point in performing any calculations if the Stack has only one or fewer elements. Assuming the results Stack has at least two values, pop them into two new Float variables, a and b. Declare a third Float variable c and initialize it to Float(O). The e variable serves as the calculated sum, difference, product, etc (e.g. c = a + b). Use a switch statement on the op parameter to determine which operator type is required. (eg case "+":). You need to push the e value back onto the results Stack and then return the string form of the e variable. The exponent() operator will require use of the Math.pow function and the doubleValue() function to convert Float objects into double values. Source History package calcrpn; 3 o import java.util.Stack; 4 public class CalcBrain implements CalcRPNOperations 7 a Stack Float> results; String operand; 8 9 Cener.java 10 public CalcBrain() { results - new StacksFloat> (); operand - 12 13 14 The digit method takes the digit input parameter and appends it to the operand variable. Then the method returns the digit. Compile and run the application. Confirm by clicking on each number 0 through 9 appears in the text area. The clearEntry method resets the operand back to the empty string. Return the string that is shown when you run the CalcRPN jar application and perform the same action. The addDecimal method adds a decimal point to the operand. Then it returns the period character. This method needs to be handled carefully because only one decimal is allowed in an operand. Use the String method contains to help you here. The enterPressed method pushes a non-blank operand (converted to a Float) onto the results Stack. (If the operand is blank, simply return a blank string). You can use Float parseFloat to convert a String object to a Float object. The operand must be reset to an empty string. You can return a single space The clear method clears the results Stack and the operand. The operator method performs the calculation work as determined by the type of operator it is passed. First the method pushes the operand value onto the results Stack if that operand is non-blank (and then resets operand blank). Then the method returns an empty string if the results Stack has less than two elements in it use the Stack's size method) because there is no point in performing any calculations if the Stack has only one or fewer elements. Assuming the results Stack has at least two values, pop them into two new Float variables, a and b. Declare a third Float variable c and initialize it to Float(O). The e variable serves as the calculated sum, difference, product, etc (e.g. c = a + b). Use a switch statement on the op parameter to determine which operator type is required. (eg case "+":). You need to push the e value back onto the results Stack and then return the string form of the e variable. The exponent() operator will require use of the Math.pow function and the doubleValue() function to convert Float objects into double values Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started