Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
This is a Data structure and algorithm code code in Java Note that the first number is handled differently than the others. If there is
This is a Data structure and algorithm code code in Java Note that the first number is handled differently than the others. If there is no operator to apply, then the number is just remembered If there is an operator, it can be applied. The SimpleMath accumulator needs to know when it's in the middle of a calculation and when it's not. It should start NOT in the middle of a calculation, and then continue in the middle of a calculation until the reset method gets called. A SimpleMath accumulator only recognizes the four operations +,, and / (plus, minus, times and divide). Other operations are ignored (as stated in the AccumulatorInterface specification. Notes Our SimpleMath accumulator does not respect the order of operations ("PEDMAS"). If we give it 10+53 it gives us 45 as the answer 10 plus 5 is 15 , multiplied by 3 is 45 . Later we may make a version that does. Note that our SimpleMath accumulator could be used in way different than our progam does. For example, you might try the following code: AccumulatorInterface sm = new simpleMath(); sm, enteroperation('+'); for (int 1=1;1 "); line = kbd.nextLine() while ( line.equals ()) \& input = new Scanner (1ine); If read number/operator until line ends try \& number = input. nextInt (); while (input, hasNext()) 1 1/ save the number sm. enterNumber (number); 1/ get the operator op = input, next () , charAt (0); sm, enteroperator (op)
code in Java
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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