第十三周上机作业
1
package ssasdhier;
import java.util.Random;
public class suiji {
public static void main(String[] args) {
int[] a=new int[10];
Random r=new Random();
for(int i=0;i<a.length;i++){
a[i]=r.nextInt(101);
}
for(int i=0;i<a.length;i++){
System.out.println(a[i]);
}
}
}
2.
package skadjklemo;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class dierti {
public static void main(String[] args) throws ParseException {
// TODO Auto-generated method stub
SimpleDateFormat CeshiFmt0 = new SimpleDateFormat("Gwd年MM月dd日");
SimpleDateFormat CeshiFmt5 = new SimpleDateFormat("今天是Gwd年的第 D 天 ,E");
Date now = new Date();
System.out.println(CeshiFmt0.format(now));
System.out.println(CeshiFmt5.format(now));
}
}
3.
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
System.out.println("输入邮箱地址");
String string = input.next();
if(string.contains("@") ==true||string.contains(".") ==true) {
int indexOf=string.indexOf("@");
int indexOf2=string.indexOf(".");
if (indexOf<indexOf2){
String substring = string.substring(0, indexOf);
System.out.println(substring);
}else{
System.out.println("邮箱不合法");
}
}else {
System.out.println("邮箱不合法");
}
}

浙公网安备 33010602011771号