I already have the program but when I run it gives me an error
"java.lang.NoSuchMethodError: main
Exception in thread "main"
Process completed."
So maybe I have something wrong.
This is my code
import javax.swing.JApplet;
import java.awt.Graphics;
import javax.swing.JOptionPane;
public class ThreeNumbers extends JApplet
{
double sum;
public void init()
{
String firstNum,
secondNum;
double number1,
number2;
firstNum = JOptionPane.showInputDialog("Enter the first floating point value: ");
number1 = Double.parseDouble(firstNum);
secondNum = JOptionPane.showInputDialog("Enter the second floating point value: ");
number2 = Double.parseDouble(secondNum);
sum = number1 + number2;
}
public void paint (Graphics g)
{
super.paint(g);
g.drawRect(15, 10, 270, 20);
g.drawString("The sum is " +sum, 25, 25);
}
}
"Process completed" sounds like you are using some sort of IDE. In that case you should check out whatever tutorials and other documentation came with it.
As far as Java is concerned the Tutorial I linked to before talks about how to run (deploy) applets. The section "Using the Applet Tag" (http://java.sun.com/docs/books/tutorial/deployment/applet/applettag.html) will prove especially useful. Note that applets exist within web pages, so you write a small web page and use the <APPLET> tag. "Running" the applet consists of displaying the web page in you web browser.
If you want to avoid writing a web page, there is the java tool appletviewer. It is described here: http://java.sun.com/javase/6/docs/technotes/tools/windows/appletviewer.html
I did it too, but when I run it gives an error message
class, interface, or enum expected
Here it is
<html>
<applet code="ThreeNumbers.class" width="300" height="65">
</applet>
</html>