Translator  

[Image]

Translator can translate a few English words into German.  It also has a quiz for counting in German.


Important Commands

if ( english.equalsIgnoreCase("hello") )
Tests whether the String english is equal to "hello", ignoring capital and small letters (case-insensitive).

io.showMessageDialog(this,german);
Shows a pop-up dialog printing the String german. 

JOptionPane io = new JOptionPane();
Creates the io object that can create dialogs.

int q = (int)(Math.random()*4) + 1
Chooses a random integer between 1 and 4.


Comments

The construct if . . else if . . else . .  is used repeatedly. In the "real world", the lists of English and German words would be in a data file, not coded directly into the program.

Notice that you must use .equals or .equalsIgnoreCase to check whether two strings are equal.  You cannot use == to compare strings.  The double equal sign is used for comparing numbers or objects, but not for Strings.