-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSomsai.java
53 lines (44 loc) · 1.41 KB
/
Somsai.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
44
45
46
47
48
49
50
51
52
53
import java.io.*;
import java.nio.Buffer;
import java.util.*;
public class Somsai {
public int check(int n){
String s=Integer.toString(n);
String s1="123456789";
if(s.length()!=10){
return 2;
}
int count=0;
for(int i=0;i<s.length();i++){
if(s1.contains(s.substring(i,i+1))){
count++;
}
}
if(count==10){
return 1;
}
return 3;
}
public static void main(String args[]) throws IOException{
Scanner sc=new Scanner(System.in);
Somsai somsai=new Somsai();
System.out.println("Enter the Phone number of Student");
String number=sc.nextLine();
System.out.println("Enter the Regno of the Studnet");
String Regno=sc.nextLine();
int num=Integer.parseInt(number);
int c=somsai.check(num);
if(c==1){
System.out.println(" the enter number is correct and is on correct format");
}else if(c==2){
System.out.println("The number doesnt have 10 digits");
}else{
System.out.println("The number doesnt have a number");
}
if(Regno.length()==9){
System.out.println("The Regno of Student is correct");
}else{
System.out.println("The regno is of Differnt Length");
}
}
}