Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to add two numbers in java

import java.util.*;
public class Add
{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter 2 numbers");
    num1=sc.nextInt();
    num2=sc.nextInt();
    int sum=num1+num2;
    System.out.println("The sum of the two numbers is: "+sum);
  }
}
 
PREVIOUS NEXT
Tagged: #add #numbers #java
ADD COMMENT
Topic
Name
7+8 =