Write a Java Program to add two numbers .
Please answer me quickly it is emergency .
Answers
Answered by
2
Answer:
Explanation:
import java.util.*;
public class ....{
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
System.out.println("input your first number.");
int a = sc.nextInt();
System.out.println("enter second number");
int b = sc.nextInt();
int c = a+b;
System.out.println("Sum = " +c);
}
}
Answered by
0
Your Program:
package com.company;
import java.util.Scanner;
class test
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter first number: ");
long n1 = sc.nextLong();
System.out.println("Enter second number: ");
long n2 = sc.nextLong();
System.out.println("The sum of the numbers: "+Math.addExact(n1,n2));
}
}
Similar questions