Perform Addition of Two Numbers in Java | Java Programs

Output:

*** Addition Of Two Numbers ***

The first number is: 10
The second number is: 20
The sum of the 10 and 20 is: 30

Click Here For Java Online Compiler

Solution:

class AdditionOfTwoNumbers {

    public static void main(String[] args) {
        int firstNumber = 10;
        int secondNumber = 20;
        int sum = firstNumber + secondNumber;
        System.out.println("*** Addition Of Two Numbers ***" + "\n");
        System.out.println("The first number is: "
                + firstNumber);
        System.out.println("The second number is: "
                + secondNumber);
        System.out.println("The sum of the " + firstNumber
                + " and " + secondNumber + " is: " + sum);
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon