I've never used the acm package before, but according to the documentation, ConsoleProgram extends Program, and the Program documentation says
Every application must either contain a "Main-Class" entry in its manifest file or include a main method that looks like this, where MyClass is the name of the program class:
public static void main(String[] args) {
new MyClass().start();
}
All of your readInt() lines are outside any methods, so are seen as instance variable declarations with initializations, which will executed just before the body of the constructor of your class, but you have not created any instances of your class anywhere.
Note that the program extends a class called ConsoleProgram. I suspect that's the class that provides the main() method that you've been asked about. I also suspect that class calls the run() method. If this is so, then your program does nothing because your run() method does nothing.
If my suspicions were right, it would have been easier to figure that out if you had written this:
The @Override annotation would have been a clue that the run() method was something that was inherited from the superclass. Notice also blank lines around the method create visual separation. That makes the code easier to read.
fred rosenberger but Junilu Lacar said that my main class is in "ConsoleProgram" witch is probably where my main method() is.
by the way i have run this same class before and everything ran but the code wasnt correct so a made modifications and then when i came to run my code nothing shows up.
When you say nothing happens, do you actually mean an empty Applet Viewer window is displayed, but your are not prompted to enter any data, and nothing printed?
never mind, i managed to run it as an applet which is better then nothing but it still did not allow me to do anything on the java applet and it gave me this message Warning: Can't read AppletViewer properties file: C:\Users\Danny\.hotjava\properties Using defaults.
You can safely ignore the warning about the property file.
I see two problems with your code:
- you are not printing the value return by your fnum() and snum() methods
- you are trying to read input before the run() method is called
Try reading input from within your run method, and print out the values returned by your methods: