Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Java code (https://www.askmehelpdesk.com/showthread.php?t=98956)

  • Jun 6, 2007, 04:40 AM
    sankulanushkul
    Java code
    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
  • Jun 6, 2007, 12:33 PM
    jstrike
    Quote:

    Originally Posted by sankulanushkul
    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.
  • Aug 22, 2008, 05:13 PM
    naimlatifi
    / / 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****

  • All times are GMT -7. The time now is 10:12 PM.