Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 91f9d4e

Browse files
Create 37.2 gmail validator.java
1 parent 65e58ae commit 91f9d4e

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

‎37.2 gmail validator.java‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
Ask the user to give his/her the Gmail id , check Gmail id is in proper format or not ? and count the number of charecters excluding @gmail.com
3+
let rules for valid mail id are
4+
1. only special symbol allowed is (.) and that must not be in staring or ending.
5+
2. @gmail.com must be prsent at last.
6+
7+
Input Format
8+
9+
First line must be a mail id
10+
11+
for Example
12+
13+
Input Format
14+
bhimasen.moharana@gmail.com
15+
16+
Output Format
17+
valid 17
18+
19+
Constraints
20+
21+
input must be a Gmail id
22+
23+
Output Format
24+
25+
First line prints "valid" or "invalid"
26+
Secondline prints Number of chars presenst inthe mail id excluding @gmail.com
27+
28+
Sample Input 0
29+
30+
bhimasen.moharana@lpu.co.in
31+
Sample Output 0
32+
33+
invalid
34+
17
35+
Explanation 0
36+
37+
invalid because it is not a Gmail id.
38+
and number of charecter =17
39+
*/
40+
41+
import java.io.*;
42+
import java.util.*;
43+
44+
public class Solution {
45+
46+
public static void main(String[] args) {
47+
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
48+
Scanner sc = new Scanner(System.in);
49+
String gmail = sc.next();
50+
char []check = gmail.toCharArray();
51+
boolean ans = true;
52+
int count =0;
53+
if(gmail.endsWith("@gmail.com"))
54+
{
55+
int n = gmail.indexOf("@gmail.com");
56+
for(int i=0;i<n;i++)
57+
{
58+
if(!((check[i] >= 'A' && check[i] <= 'Z') || (check[i] >='a') && (check[i] <= 'j')))
59+
{
60+
System.out.println("invalid");
61+
ans = false;
62+
}
63+
}
64+
if(ans)
65+
System.out.println("valid");
66+
}
67+
else
68+
{
69+
System.out.println("invalid");
70+
}
71+
int ct = gmail.indexOf("@");
72+
System.out.print(ct);
73+
}
74+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /