码迷,mamicode.com
首页 > 编程语言 > 详细

Java验证码程序

时间:2017-10-08 18:05:45      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:ane   随机   ati   利用   for   string   imp   als   es2017   

1、设计思想

利用random和for循环进行程序的实现

2、流程图

技术分享

3、源代码

import javax.swing.JOptionPane;
public class jiemiansheji
{
public static void main(String[] args)
{

String result = "";

for(int i = 0 ; i < 6 ; i ++)
{

int intVal = (int)(Math.random() * 26 + 97);

result = result + (char)intVal;
}

String str;
str=JOptionPane.showInputDialog("输入验证码\n"+result);
if(str.equals(result))
{
JOptionPane.showMessageDialog(null,"验证成功","",JOptionPane.PLAIN_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(null,"验证失败","",JOptionPane.PLAIN_MESSAGE);



}
}
}

4、实验截图

技术分享

技术分享

技术分享

5、实验总结

通过上网查询以及运用课件代码成功地生成了随机验证码,并且使程序成功运行

 

Java验证码程序

标签:ane   随机   ati   利用   for   string   imp   als   es2017   

原文地址:http://www.cnblogs.com/bangandwolf/p/7637919.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!