"geletine" <> wrote in news:1138041018.041233.9440
@z14g2000cwz.googlegroups.com:
>
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> import java.io.*;
Jeroen already gave you the answer to your problem, but I'd like to
offer some additional advice.
What classes of package java.awt are you using? Examine all your import
statements, and see if you really need them. Don't import packages you
don't use. And when you only need one or two classes from a package,
import only those classes, not the whole package.
> public class currencyc
For readability, you should always follow the convention of starting
class names with a capital letter.
> public static void main (String args [])throws IOException
Where is that IOException being thrown? Which statement in your main
method throws it? You shouldn't have a method throw an exception unless
it actually has a throw statement, or if a method it uses throws one.
Also, main should never throw an exception. Catch any exceptions that
are thrown inside your main method, and handle them gracefully.
> double pounds,dollars;
> String money, answer,y;
Avoid using package access when private will suffice. In particular,
use "private double pounds". Even better, when you only need a variable
in one method, declare it as local in that method.
Where do you use the y variable? Don't declare variables you don't
need.
> pounds = Double.parseDouble(money);
One of the 10 commandments of C/C++ is "always check your input". I
would say this goes for every programming language. If the user enters
"hello" into the input dialog, you should be able to recover from this.
If your course hasn't covered exceptions yet, ignore this comment.
Good luck with your studies, and have fun