fork download
  1. | a b stdout |
  2. stdout := FileStream stdout.
  3. FileStream stdin
  4. linesDo: [ :line |
  5. line isEmpty ifFalse: [
  6. (a isNil)
  7. ifTrue: [ a := line asNumber ]
  8. ifFalse: [ b := line asNumber ].
  9. ].
  10. ].
  11.  
  12. stdout nextPutAll: '和: '; nextPutAll: (a + b) printString; nl;
  13. nextPutAll: '差: '; nextPutAll: (a - b) printString; nl;
  14. nextPutAll: '積: '; nextPutAll: (a * b) printString; nl.
  15.  
  16. b = 0
  17. ifTrue: [
  18. stdout nextPutAll: 'ゼロで割ろうとしています'; nl
  19. ]
  20. ifFalse: [
  21. stdout nextPutAll: '商: '; nextPutAll: (a / b) printString; nl;
  22. nextPutAll: '剰余: '; nextPutAll: (a \\ b) printString; nl.
  23. ].
  24.  
  25. stdout flush.
  26.  
Success #stdin #stdout 0.01s 7872KB
stdin
8
7
stdout
和: 15
差: 1
積: 56
商: 8/7
剰余: 1