Friday, September 4, 2015

using dialog box with ParseInt method in java

This method is used to get the primitive data type of a certain String. It's also a static method.
 
 
 
 
 
import javax.swing.JOptionPane;

public class Apples {

public static void main(String[] args){



JOptionPane.showMessageDialog(null,"enter 2 numbers you wanna add ");

// show input dialog method , receives input as a string

String first = JOptionPane.showInputDialog("enter 1st number");

String second = JOptionPane.showInputDialog("enter 2nd number");

// converting strings into integers by ParseInt method

int message = (Integer.parseInt(first) + Integer.parseInt(second) );

// dislpaying the result

JOptionPane.showMessageDialog(null, message);


}

}
 
thank you.

Next we are going talk about If statement.

2 comments:

  1. I like the way you only do little sections at a time it doesn't overwhelm that way . Thank you !!! I look forward to the next class . Nice class !!!

    ReplyDelete
  2. I like the way you only do little sections at a time it doesn't overwhelm that way . Thank you !!! I look forward to the next class . Nice class !!!

    ReplyDelete