fork download
  1. "your code goes here"
  2. | a b stdout |
  3. stdout := FileStream stdout.
  4. FileStream stdin 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 10164KB
stdin
Standard input is empty
stdout
Object: nil和:  error: did not understand #+
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #+ (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:12)
Object: nil商:  error: did not understand #/
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #/ (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:21)