Log in

View Full Version : Java code


sankulanushkul
Jun 6, 2007, 04:40 AM
Please give me a simple java code for addition of two numbers here two numbers are accepted

From users please give me explanation about each code

jstrike
Jun 6, 2007, 12:33 PM
please give me a simple java code for addition of two numbers here two numbers are accepted

from users please give me explaination about each code
Instead of us doing your homework why don't you post some code that you've written and we'll be glad to help you with it.

naimlatifi
Aug 22, 2008, 05:13 PM
/ / Addition two numbers
import javax.swing.*;// this package call in JOptionPane
public class Addition
{ public static void main(String args[])
{
String fristNumber;
String secondNumber;
String result;

int number1;
int number2;
// Ask the user to input two number

firstNumber=JOptionPane.showInputDialog(''Enter first number'');
secondNumber=JOptionpane.showInputDialog(''Enter second number'');

// Methods below convert from string to int

number1=Integer.parseInt(firsNumber);
number2=Integer.parseInt(secondNumber);
// formule that make addition of two numbers


result=number1+number2;

JOptionPane.showMessageDialog(null, '' the addition of two number is''+result); // Message dialog that will show the addition of two numbers

}
}




I hope that this will help you !


****Naim****