FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 67   



Following program shows you how to take two numbers from user and add those two numbers.
In this program we take two numbers from user using Scanner method and add those two numbers

import java.util.Scanner;

public class BasicMath1 {

    public static void main(String[] args) {

        int input1;
        int input2;

        Scanner in = new Scanner(System.in);

        System.out.println("Enter first number:");
        input1 = in.nextInt();

        System.out.println("Enter second number:");
        input2 = in.nextInt();

        int result = input1 + input2;

        System.out.println("Sum of the given two numbers is: " + result);
    }

}

Output:

Enter first number:
20
Enter second number:
30
Sum of the given two numbers is: 50



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News