zoukankan      html  css  js  c++  java
  • 字符串示例

    package java15;

    import java.util.Scanner;

    public class Demo6 {

    public static void main(String[] args) {
      boolean fileCorrect=false;
      boolean emailCorrect=false;
        System.out.println("***欢迎进入作业提交系统***");
      Scanner input=new Scanner (System.in);
        System.out.println("请输入java的文件名:");
          String name=input.next();
        System.out.println("请输入您的邮箱:");
          String email=input.next();

    //检查java文件名
        int index=name.lastIndexOf(".");
      if(index!=-1 && index!=0 && name.substring(index+1,name.length()).equals("java")) {
        fileCorrect=true;
      }else {
          System.out.println("文件名无效");
      }
    //检查您的邮箱
      if(email.indexOf('@')!=-1 && email.indexOf(".")>email.indexOf('@')) {
        emailCorrect=true;
      }else {
          System.out.println("您的E-mail无效!");
      }

    //检查结果
      if(fileCorrect && emailCorrect) {
          System.out.println("作业提交成功!");
      }else {
          System.out.println("作业提交失败!!");
        }
      }

    }

  • 相关阅读:
    【回溯】数字排列问题
    Price List
    NanoApe Loves Sequence-待解决
    【回溯】n皇后问题
    安卓 学习之旅 入门
    mysql链接 显示 error: 'Access denied for user 'root'@'localhost' (using password: NO)'
    javaweb 实战_1
    java 插件安装
    leetcode 最长有效括号
    hdu 1074 Doing Homework
  • 原文地址:https://www.cnblogs.com/wnwn/p/9810888.html
Copyright © 2011-2022 走看看