Numbers
Posted: Fri Oct 30, 2009 4:02 am
Hi, I'm a complete newcomer to Textpad and I don't know how to add numbers.
Here's my code so far:
import javax.swing.JOptionPane;
public class ThreeNumbers
{
public static void main(String[] args)
{
String s1 = JOptionPane.showInputDialog("Enter the first number:");
String s2 = JOptionPane.showInputDialog("Enter the second number:");
String s3 = JOptionPane.showInputDialog("Enter the third number:");
int num1 = Integer.parseInt(1);
int num2 = Integer.parseInt(1);
int num3 = Integer.parseInt(1);
total = num1 + num2 + num3;
System.out.println ("The answer is " + total);
}
}
------------------------------
Can someone please lay out the exact code for how I add num1 2 and 3 and get the total to display when I run and compile it.
Thank you!
Here's my code so far:
import javax.swing.JOptionPane;
public class ThreeNumbers
{
public static void main(String[] args)
{
String s1 = JOptionPane.showInputDialog("Enter the first number:");
String s2 = JOptionPane.showInputDialog("Enter the second number:");
String s3 = JOptionPane.showInputDialog("Enter the third number:");
int num1 = Integer.parseInt(1);
int num2 = Integer.parseInt(1);
int num3 = Integer.parseInt(1);
total = num1 + num2 + num3;
System.out.println ("The answer is " + total);
}
}
------------------------------
Can someone please lay out the exact code for how I add num1 2 and 3 and get the total to display when I run and compile it.
Thank you!