package cn.yang.qian.qian; import java.util.Scanner; public class average1 { public static void main(String[] args) { // 第一题 计算平均分 Scanner input = new Scanner(System.in); System.out.println("请输入语文成绩"); double Chinese = input.nextDouble(); System.out.println("请输入数学成绩"); double Math = input.nextDouble(); System.out.println("请输入英语成绩"); double English = input.nextDouble(); double sum = Chinese + Math + English; double average = sum / 3; System.out.println("总成绩是:" + sum); System.out.println("平均分是:" + average); } } package cn.yang.qian.qian; public class shopping2 { public static void main(String[] args) { // 第二题 购物清单 int bagPrice = 198; int badmintonPrice = 90; int battledorePrice = 400; System.out.println("********** 购 物 清 单 **********"); System.out.println("商品名称" + " " + "单价" + " " + "数量" + " " + "总价"); System.out.println("登山包" + " " + "¥" + bagPrice + " " + "1" + " " + "¥" + bagPrice * 1); System.out.println("羽毛球" + " " + "¥" + badmintonPrice + " " + "3" + " " + "¥" + badmintonPrice * 3); System.out.println("羽毛球拍" + " " + "¥" + battledorePrice + " " + "1" + " " + "¥" + battledorePrice * 1); System.out.println("=============================="); int sum = bagPrice * 1 + badmintonPrice * 3 + battledorePrice * 1; int money = 8888; int change = money - sum; System.out.println("应付金额:" + sum + "元"); System.out.println("实收金额:" + money + "元"); System.out.println("找零:" + change + "元"); } } package cn.yang.qian.qian; import java.util.Scanner; public class performance3 { public static void main(String[] args) { // 第三题 接收成绩 分等级 double student[] = new double[10]; double sum = 0;// 总成绩 double score = 0;// 平均分 Scanner input = new Scanner(System.in); for (int i = 0; i < student.length; i++) { System.out.println("请输入第" + (i + 1) + "名学生的成绩"); student[i] = input.nextDouble(); if (student[i] > 100 || student[i] < 1) { System.out.println("输入成绩无效"); break; } sum = sum + student[i]; score = sum / 10; } if (score >= 1) { int a = (int) score / 10; switch (a) { case 10: case 9: System.out.println("该班级学员等级为A"); break; case 8: System.out.println("该班级学员等级为B"); break; case 7: System.out.println("该班级学员等级为C"); break; case 6: System.out.println("该班级学员等级为D"); break; case 5: case 4: case 3: case 2: case 1: case 0: System.out.println("该班级学员等级为E"); break; } } } } package cn.yang.qian.qian; public class test4 { public static void main(String[] args) { // 第四题 输出1~1000之间5的倍数 并统计个数 int conut = 0; System.out.println("1~1000之间5的倍数为:"); for (int i = 1; i <= 1000; i++) { if (i % 5 != 0) { continue; } else { conut++; if (conut % 8 == 0) { System.out.println(i); } else { System.out.print(i + " "); } } } System.out.println("1~1000之间5个倍数一共有" + conut + "个"); } } package cn.yang.qian.qian; import java.util.Arrays; import java.util.Scanner; public class test5 { public static void main(String[] args) { // 第五题 录入成绩 按降序排列 int student[] = new int[10]; int a = 0; int b = 0; int c = 0; Scanner input = new Scanner(System.in); System.out.println("学员成绩统计表"); for (int i = 0; i < student.length; i++) { System.out.println("请输入第" + (i + 1) + "个学员的成绩"); student[i] = input.nextInt(); } System.out.println("********************************"); System.out.println("降序输出所有成绩为:"); Arrays.sort(student);// 排序 for (int i = student.length - 1; i >= 0; i--) { System.out.print(student[i] + " "); if (student[i] >= 80 && student[i] <= 100) { a++; } if (student[i] >= 60 && student[i] < 80) { b++; } if (student[i] < 60) { c++; } } System.out.println(" "); System.out.println("********************************"); System.out.println("其中:"); System.out.println("100分--80分的学员有:" + a + "个"); System.out.println("79分--60分的学员有:" + b + "个"); System.out.println("60分以下的学员有:" + c + "个"); } } package cn.yang.qian.qian; import java.util.Arrays; import java.util.Scanner; public class test6 { public static void main(String[] args) { // 输入数据 判断是否存在数组中 int qianqian[] = new int[5]; Scanner input = new Scanner(System.in); for (int i = 0; i < qianqian.length; i++) { System.out.println("请输入第" + (i + 1) + "个数字"); qianqian[i] = input.nextInt(); } System.out.print("所接受的数字为:["); for (int qian : qianqian) { System.out.print(qian + ","); } System.out.println("]"); System.out.println("请输入查询数字"); int number = input.nextInt(); int count = Arrays.binarySearch(qianqian, number); if (count == -1) { System.out.println("该数字不存在与本数组中"); } else { System.out.println("该数字是本数组中第:" + (count + 1) + "个成员"); } String str = Arrays.toString(Arrays.copyOf(qianqian, number)); if (count == 0) { System.out.println("该数字前无数据"); } else { System.out.println("该数字前的数组内容为:" + str); } } }