October 1st, 1999, 09:06 PM
I need to create an applet that will read in two integers then print out thier sum,
this is what I have but it's not working, I'm sure I did plenty wrong and would really
appreciate some help...
import javax.swing.JApplet;
import java.awt.Graphics;
import javax.swing.JOptionPane;
public class TwoNum extends JApplet {
public void main(String args[]){
String num1,num2;
int n1,n2,sum;
num1 = JOptionPane.showInputDialog("Please type an integer:");
num2 = JOptionPane.showInputDialog("Please type another integer:");
n1 = Integer.parseInt(num1);
n2 = Integer.parseInt(num2);
sum = n1 + n2;
JOptionPane.showMessageDialog(null,n1+" + "+n2+" = "+sum,"Results",JOptionPane.PLAIN_MESSAGE);
}
}
I've never done a JApplet before and I think alot may be wrong with my first atempt,
any and all help would be great, thanks!
this is what I have but it's not working, I'm sure I did plenty wrong and would really
appreciate some help...
import javax.swing.JApplet;
import java.awt.Graphics;
import javax.swing.JOptionPane;
public class TwoNum extends JApplet {
public void main(String args[]){
String num1,num2;
int n1,n2,sum;
num1 = JOptionPane.showInputDialog("Please type an integer:");
num2 = JOptionPane.showInputDialog("Please type another integer:");
n1 = Integer.parseInt(num1);
n2 = Integer.parseInt(num2);
sum = n1 + n2;
JOptionPane.showMessageDialog(null,n1+" + "+n2+" = "+sum,"Results",JOptionPane.PLAIN_MESSAGE);
}
}
I've never done a JApplet before and I think alot may be wrong with my first atempt,
any and all help would be great, thanks!