zoukankan      html  css  js  c++  java
  • 验证码

    1.设计思路

    利用random和循环生成随机六位字符串作为验证码,然后根据提示输入,接着判断是否正确。

    2.流程图

    3.源代码

    import javax.swing.JOptionPane;
    public class Vcode
    {
    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 code;
    code=JOptionPane.showInputDialog(result+" 请输入验证码");
    if(code.equals(result))
    {
    JOptionPane.showMessageDialog(null,"验证通过","验证结果",JOptionPane.PLAIN_MESSAGE);
    }
    else
    {
    JOptionPane.showMessageDialog(null,"验证失败","验证结果",JOptionPane.PLAIN_MESSAGE);
    }

    }

    }

    4.截图

  • 相关阅读:
    idea的常识
    开发工具
    常用的正则表达式
    比较器
    索引
    final区别
    GC
    String StringBuffer
    类库
    线程的操作状态
  • 原文地址:https://www.cnblogs.com/sakura--/p/7637737.html
Copyright © 2011-2022 走看看