首页 > 其他 > 详细

实验一任务四:验证码问题

时间:2017-09-30 09:19:37      阅读:259      评论:0      收藏:0      [点我收藏+]

package shiyansi;

import javax.swing.JOptionPane;
public class RandomStr {

public static void main(String[] args) {
// TODO 自动生成的方法存根
//定义一个空字符串

String result = "",first;
int number1,number2;
//进行6次循环
for(int i = 0 ; i < 6 ; i ++)
{
//生成一个97~122的int型的整数
int intVal = (int)(Math.random() * 26 + 97);

//将intValue强制转换为char后连接到result后面
result = result + (char)intVal;
}

first =
JOptionPane.showInputDialog( "The code is:"+result);


if(first.equals(result))//判断是否输入正确正确输出Success错误输出Error
{
JOptionPane.showMessageDialog(
null, "Success! "

);
System.exit( 0 ); //退出程序
}
else
{
JOptionPane.showMessageDialog(
null, "Error!"

);
System.exit( 0 ); //退出程序
}

}

}

实验一任务四:验证码问题

原文:http://www.cnblogs.com/mqlblog/p/7613251.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!