-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path8.2 Validate Mobile Number.java
43 lines (31 loc) · 1.07 KB
/
8.2 Validate Mobile Number.java
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
Alex has a friend from India .He want to save the Mobile number of his friend with 91 extension .Help Alex to store the contact number of his friend in apporpriate mannner and If the number is valid then print "Number Saved” else print ”Enter Valid Number”.
Input Format
In First input line, you should enter contact number of Alex friend.
Constraints
Enter only positive value.
N
Output Format
Print “Number Saved” else print ”Enter Valid Number”.
Sample Input 0
919872436366
Sample Output 0
Number Saved
*/
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
String number = sc.next();
if(number.charAt(0)=='9' && number.charAt(1)=='1' && number.length()==12)
{
System.out.print("Number Saved");
}
else
{
System.out.print("Enter Valid Number");
}
}
}