2016년 11월 15일 화요일

Calculator works


I've been for awhile now trying to figure out how I can make a an average button for my calculator emulator. Been having ideas with making a list and so on to make it as an actual averager as in a actual calculator. If anyone can help me with this I'd gladly appreciate it.

--
Initialize a global list called stack, to create empty list.

In the Clear All button, set global stack to empty list.

Have a numeric text box, and an Enter button.
In the Enter button, insert textbox.Text before position 1 of Stack.

Code a value procedure list_to_lines to take a list input, 
run it thru a list to csv block, text replace all commas with \n ,
and return the result.

Each time you change the stack, show its lines conversion in a label.
(optional).

Code a sum() value procedure that takes a list input,
uses a local variable subtotal initially 0,
and a do-result block that returns subtotal.
 In the do block, code a for each item in list
      set subtotal to subtotal + item

When the Average  button is pressed,
show sum(stack)/length of list(stack).

ABG
FAQ:

-- 
I'm having a hard time understanding the procedure to follow by your steps, I've been trying to figure this out for a while now sorry. 

-- 
See the Books and Tutorials section of the FAQ.
Look for the "How to" link in the FAQ also.

Then post a downloaded image of your blocks here.

-- 
See attached for an average procedure.

 average.png
-- 

댓글 없음:

댓글 쓰기