Wap to calculate the sum of two numbers how to do java
Answers
Answered by
0
Answer:
Java program to add two numbers, a user enters two integers, and we calculate their sum and display it. Using int data type, we can add numbers up to a limit (range of int data type). If you want to add very large numbers, then you may use BigInteger class.
Explanation:
make me a brain list
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
Math,
3 months ago
Math,
3 months ago
Science,
3 months ago
Psychology,
6 months ago
Political Science,
11 months ago