Computer Programming with GNU Smalltalk - Free
Computer Programming with GNU Smalltalk - Free
Computer Programming with GNU Smalltalk - Free
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
value, directly.<br />
Answers of Review Questions 93<br />
3. Messages are classified as unary, binary and keyword messages. We can count reverse and<br />
asUppercase as examples of unary messages; count + and * as binary messages; count at:put:<br />
and removeKey: as keyword messages.<br />
4. We can deal <strong>with</strong> natural numbers like 3, 10, 25; real numbers like 3.5, 8.2, 0.4e5 or fractions<br />
like 4/7, 8/13, 25/138.<br />
5.<br />
6.<br />
7.<br />
"answer_3_5.st"<br />
| theNumber |<br />
Transcript show: 'Please enter a number to get its cube: '.<br />
theNumber := stdin nextLine.<br />
Transcript show: 'The cube of ', theNumber, ' is ', (theNumber asInteger<br />
squared * theNumber asInteger) printString, '.'; cr.<br />
Please enter a number to get its cube: 3<br />
The cube of 3 is 27.<br />
"answer_3_6.st"<br />
| theNumbers arithmeticAverage |<br />
Transcript show: 'Please enter two numbers separated by space to get their<br />
arithmetic average: '.<br />
theNumbers := stdin nextLine tokenize: ' '.<br />
arithmeticAverage := ((theNumbers at: 1) asInteger + (theNumbers at: 2)<br />
asInteger) / 2.<br />
Transcript show: 'The arithmetic average of ', (theNumbers at: 1), ' and ',<br />
(theNumbers at: 2), ' is ', arithmeticAverage printString, '.'; cr.<br />
Please enter two numbers separated by space to get their arithmetic<br />
average: 10 20<br />
The arithmetic average of 10 and 20 is 15.<br />
"answer_3_7.st"<br />
| definitions theWord |