📄 j02050611.java
字号:
import java.lang.*;
import javax.swing.*;
class j02050611
{
public static void main(String para[])
{
String chkStr;
boolean hasSpace; //mail 是否含有空格符
int countChar; //计算有几个@字符
first:
while( true )
{
countChar = 0;
hasSpace = false;
chkStr = JOptionPane.showInputDialog(null,
"请输入你的 mail 帐号\n或输入'%'来离开").trim();
// 去掉尾部的空白
second:
for( int x=0 ; x<chkStr.length() ; x++ )
{
if( chkStr.charAt(x)=='@')
{
countChar = countChar + 1;
if(countChar>1)
break second; // 不能超过 1 个 @ 符号
}
if( chkStr.charAt(x)==' ')
{ // 该字符为空格时
hasSpace = true;
break second;
}
if( chkStr.charAt(x)=='%')
{
JOptionPane.showMessageDialog(null,
"你输入了'%',现在程序将关闭!");
break first;
}
} // second 标注之循环的结尾
if( hasSpace == true)
{
JOptionPane.showMessageDialog(null, "mail 帐号中不可以含有空格符");
}
else if (countChar!=1)
{
JOptionPane.showMessageDialog(null, "请输入有效的 mail 帐号");
}
else
{
JOptionPane.showMessageDialog(null,"您己经加人期刊订阅会员\n"
+ "本站将会定期寄信息到您的 mail:\n"+ chkStr);
break first; // 已输入有效 mail,离开标注 first 卷标的循环
}
} // first 标注之循环的结尾
System.exit(0); //结束程序的执行
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -