Java SE for Tester Student

2018-3-5 16:36
请先登录。
其中考试编程题答案:

五、编程题(共25分)
1. (5分)
	public static boolean isRepeat(int[] num){
		int count = 0;
		for(int i = 0; i < num.length; i++){
			for(int j = i + 1; j < num.length; j++){
				if(num[i] == num[j]){
					count++;
					System.out.println(num[i]);
				}
			}
		}
		if(count == 0) {
			System.out.println("没有重复元素");
			return false;
		}else{
			System.out.println("重复元素总个数:" + count);
		    return true;
		}
	}
2. (5分)
public static void main(String args[]){
	    Scanner sc = new Scanner(System.in);
	    System.out.println("请输入用户名:");
	    String name = sc.nextLine();	
	    System.out.println("请输入密码:");   
	    String password = sc.nextLine();
        if(name.equals("ABC") && password.equals("123")){
        	System.out.println("登录成功");
        }else{
        	System.out.println("登录失败");
        }
	}
3. (15分)
public class School {
	private double line;
	public double getLine() {
		return line;
	}
	public void setLine(double line) {
		this.line = line;
	}	
}
public class Student {
	private String name;
	private String examNo;
	private double totalScore;
	private double sportScore;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getExamNo() {
		return examNo;
	}
	public void setExamNo(String examNo) {
		this.examNo = examNo;
	}
	public double getTotalScore() {
		return totalScore;
	}
	public void setTotalScore(double totalScore) {
		this.totalScore = totalScore;
	}
	public double getSportScore() {
		return sportScore;
	}
	public void setSportScore(double sportScore) {
		this.sportScore = sportScore;
	}
}
public class Matriculate {

    public boolean isEnroll(Student stu, School school){
    	if(stu.getTotalScore() >= school.getLine()){
    		System.out.println("考号:" + stu.getExamNo()
    		+" 姓名:" + stu.getName() + " 被录取");
    		return true;
    	}else if(stu.getSportScore() > 96 && stu.getTotalScore() > 300){
    		System.out.println("考号:" + stu.getExamNo()
    		+" 姓名:" + stu.getName() + " 被录取");
    		return true;
    	}else{
    		return false;
    	}
    }
	public static void main(String[] args) {
		Student stu = new Student();
		stu.setName("张三");
		stu.setExamNo("2018001002");
		stu.setSportScore(89.0);
		stu.setTotalScore(450.0);
		School school = new School();
		school.setLine(449.0);		
		Matriculate matr = new Matriculate();
		matr.isEnroll(stu, school);
	}
}

创建了 #Java SE for Tester Student# 任务:

任务十二 统计英文文档中每个单词出现的次数
1 自己找一篇英文文档贴到记事本上;(src.txt)2 将结果输出到另一个记事本中(resultRecorder.txt)3 可能会用到的正则表达式:"\\s+"