Skip to content

Commit e7c0115

Browse files
Create 40.1 String Conversion Wrapper Class.java
1 parent 7ffd461 commit e7c0115

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Amit purchased one calculator for performing some calculation on it. He is running a company which develop machines. He want to calculate total sale of today. But he is not able to calculate sum of two numbers because numbers are having more than nine digits. Help the Amit to calculate sum of two integer values having more than 9 digits ao that he will be able to do calculations.
3+
4+
Input Format
5+
6+
First line will contain one integer value having more than nine digits.
7+
Second line will contain one integer value having more than nine digits.
8+
9+
Constraints
10+
11+
Number of digits in numbers will lie between 10-20.
12+
13+
Output Format
14+
15+
Sum of two integer values if numbers satisfy the constraint else print Invalid Input
16+
17+
Sample Input 0
18+
19+
12
20+
13
21+
Sample Output 0
22+
23+
Invalid Input
24+
Sample Input 1
25+
26+
111112222233333
27+
111118777701111
28+
Sample Output 1
29+
30+
222230999934444
31+
*/.import java.io.*;
32+
import java.util.*;
33+
34+
public class Solution {
35+
36+
public static void main(String[] args) {
37+
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
38+
Scanner sc = new Scanner(System.in);
39+
String s1 = sc.next();
40+
String s2 = sc.next();
41+
if(s1.length()<9 || s2.length()<9)
42+
{
43+
System.out.print("Invalid Input");
44+
System.exit(0);
45+
}
46+
long i1 = Long.parseLong(s1);
47+
long i2 = Long.parseLong(s2);
48+
System.out.print(i1+i2);
49+
}
50+
}

0 commit comments

Comments
 (0)