4.3 Exercises



1. Temperature Conversion

2. Secret language

The following applet consists of an input field in which you can enter text and of an echo of the text string in the inout field with each letter in the alphabet replaced by its successor (in terms of Unicode characters: a (A) becomes b (B), b (B) becomes c (C), ...., y (Y) becomes z (Z), and z (Z) becomes { ([)). For example, the text Ana in the input field is echoed as Bob.

Write the Java code for this applet.

3. Vowels, Consonants, and Other Characters

Make the following applet that counts the number of vowels, consonants, and other characters.

4. Gambler's Ruin

Adapt and extend the Java code of the Gambler's Ruin example in such a way that Sarah's amount during one game is displayed as follows:
--> java OneGame

Sarah's amount of money during the game:
__________
___________
____________
___________
____________
___________
____________
___________
____________
___________
____________
_____________
______________
_______________

Game Length is 13
Winner is Sarah
The source code that you can use is contained in the files

5. Combinatorics