import java.util.Scanner;
//邮箱练习题
public class ttt {
public static void main(String[] args) {
System.out.print("请输入你的邮箱:");
Scanner scanner = new Scanner(System.in);
String str = scanner.next();
int a = str.indexOf("@");
int b = str.indexOf(".");
if (a<=0 && b<=0){
System.out.println("邮箱缺少@或者.");
return;
}else if (a>b){
System.out.println("@必须在.之前");
return;
}else if (b-a==1){
System.out.println("@必须和.之间有一个字符以上");
return;
}else if (a<2){
System.out.println("@之间有2个字符以上");
return;
}
String c = str.substring(b+1);
if(! (c.equals("cn") || c.equals("com") || c.equals("net"))){
System.out.println("后缀不符合!!");
return;
}
System.out.println(str);
}
}
11-18
727
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-09
514
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-06
223
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)