Question: A C# question: Why would one use accumilator? Why instead of a local variable and return it, would one want to use accumilator? Thank you

A C# question:

A C# question: Why would one use accumilator? Why instead of a

Why would one use accumilator? Why instead of a local variable and return it, would one want to use accumilator?

Thank you :)

public double Divide double dividend, double divisor) public double Accumulator {get; private set; } public void Clear() public double Add (double addend) public double Subtract(double subtractor) public double Multiply(double multiplier) public double Divide (double divisor) public double Power (double exponent) Return the result of the division dividend/divisor. Consider what should happen when a division by zero is attempted. Test it. Add the C# property Accumulator to the Calculator class. It should always contain the result of the latest operation. Consider what it should contain, initially and when errors happen. Test it accordingly. This method should clear the accumulator to contain zero. Make overloads of the calculation functions with one parameter less than the original. The missing operand is always taken from the accumulator, thus making it possible to make chained calculations like on a real calculator. The methods returns the result and changes the accumulator. Consider error situations. Test everything. Check the result of your Power function. Are you satisfied with the results from strange combinations of operands, e.g. negative x with non-integer exponent? Do you need another exception? Test the implementation of your decisions. (no new function)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!