We spent a couple weeks writing command-line (text-mode) programs. This is the "old-fashioned" style of user-interfaces.
Modern operating systems use graphics mode almost all the time. This is called GUI - Graphical User Interface. The operating system displays Windows, Icons (buttons), Menus, and a Pointer (mouse), so it is also called a WIMP system.
Java includes libraries of prewritten code that can display normal GUI elements - buttons, menues, lists, text boxes, graphics images, etc. Unfortunately these GUI elements are rather difficult for beginners to use. But you can use EasyApp to make it reasonably simple.
EasyApp was written by Dave Mulkey to enable beginning programmers (especially high school students) to work easily in a modern, familiar GUI environment. You can read more about EasyApp here: http://ibcomp.fis.edu/java/EasyApp.html
The main thing you need to know about EasyApp is how to use it.
The program below displays a window with 2 buttons - 1 for converting from Euros to Dollars, and another for converting Euros to Pounds.
|
import java.awt.*; Button dollars = addButton("Dollars",50,50,100,30,this); |
Notice the following about the program:
You can add as many buttons as you want - just remember to also add an if... command to respond. And be careful with the coordinates, so the buttons don't overlap on the screen.
(1) Download EasyApp, then copy the Changer program (above) and get it running.
(2) Change the Dollars code so that it asks how many Euros you have, and then changes that many Euros to Dollars.
(3) Add another Button for changing from Euros to some other currency. Use Google to find the correct exchange rate. Remember that you must make a new Button and ALSO add an if... command in the actions method.
(4) Add a fourth button that inputs a price and then adds sales tax to it. For example, in California if you buy a shirt for 20 dollars, the store adds 8% sales tax, so you must pay 20 + 1.60 = 21.60 .