-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBigINTJava.txt
29 lines (19 loc) · 980 Bytes
/
BigINTJava.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) { //this works as (scanf("%d",&num)!=EOF)
BigInteger num = BigInteger.ZERO; //initializing the variable with zero
BigInteger num2 = BigInteger.ZERO;
BigInteger num3 = BigInteger.ONE;
BigInteger num4 = BigInteger.ZERO;
num = in.nextBigInteger(); //taking the input
num2 = in.nextBigInteger();
num3 = num.add(num2); //addition num3 = num + num2;
System.out.println("Sum: " + num3);
num4 = num.subtract(num2); //subtraction num3 = num - num2;
System.out.println("Difference: " + num4);
}
}
}