第十三周上机练习

1.

package text;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
public class Zuoyee {
    public static void main(String[] args) {
        int arr[] = new int[11];
          Random r = new Random();
          for (int i = 0; i < 10; i++) 
          {
           System.out.println(r.nextInt(100) + 1);
          }
    }
}

2.

package text;
import java.text.*;
import java.util.*;
public class Text2 {
    public static void main(String[] args) throws Exception {
        SimpleDateFormat sdf=new SimpleDateFormat("Gyyyy年MM月dd日:今天是yyyy年的第D天,E");
        System.out.println(sdf.format(new Date()));
    }

}

3.

package text;
import java.util.Scanner;
public class LH {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        System.out.println("请输入邮箱:");
        String a=input.next();
        if(a.contains("@") ==true||a.contains(".") ==true) {
            int a1=a.indexOf("@");
            int a2=a.indexOf(".");
           if (a1<a2){
               String substring = a.substring(0, a1);
               System.out.println(substring);
           }else{
               System.out.println("邮箱不合法");
           }
        }else {
            System.out.println("邮箱不合法");
        }
        
    }

}

 

posted @ 2020-05-28 14:06  计算机1804梁浩  阅读(142)  评论(0编辑  收藏  举报