// 输入一个邮箱,判断 邮箱是否有效( 规则为:1.有一个@,且不在第一个字符 2. 有一个.且在@后,中间至少有一个字符隔开 ),
//接着取出邮箱名后,输出欢迎您,xx.
import java.util.Scanner;
public class Indexof {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("输入你的邮箱");
String s=sc.nextLine();
if(Test(s)){
System.out.println("成功");
System.out.println(s.substring(s.indexOf("@")+1,s.indexOf("."))+"欢迎宁,"+s.substring(0,s.indexOf("@")));
}else {
System.out.println("失败");
}
}
public static boolean Test(String s){
if(s.indexOf("@")<=0 ){
return false;
}
if(s.indexOf("@")-s.indexOf(".")<1 && s.indexOf(".")<0){
return true;
}
return true;
}
}