1. Java三大特性: 封装、继承、多态;
    2. 定义三个参数, a,b; 交换 a,b的值

    例如:
    输入: 1 5
    输出:a = 5 ; b = 1

    1. public class Demo1 {
    2. public static void main(String[] args) {
    3. int a, b, temp;
    4. Scanner input = new Scanner(System.in);
    5. a = input.nextInt();
    6. b = input.nextInt();
    7. temp = a;
    8. a = b;
    9. b = temp;
    10. System.out.println("a = " + a + ";b = " + b);
    11. }
    12. }

    控制台输出

    1 5
    a = 5;b = 1

      1. 定义 一个数组; 输入10个数(x>=0&&x<=100);将这10个数分为3个等级;

    例如 :

    1. 输入: 59 60 70 80 88 45 90 100 95 96
    2. 输出: A: 4 B: 4 C:2
    1. package Weekly_Task;
    2. import java.util.Scanner;
    3. /**
    4. * @author Devil
    5. * @create 2021-10-24-20:27
    6. */
    7. public class Demo2 {
    8. public static void main(String[] args) {
    9. Scanner input = new Scanner(System.in);
    10. int countA = 0, countB = 0, countC = 0;
    11. int[] array = new int[10];
    12. for (int i = 0; i < array.length; i++) {
    13. array[i] = input.nextInt();
    14. if(array[i]<=100&&array[i]>=90){
    15. countA++;
    16. }else if(array[i]>=60&&array[i]<90){
    17. countB++;
    18. }
    19. else {
    20. countC++;
    21. }
    22. }
    23. System.out.println("A:"+countA+" B:"+countB+" C:"+countC);
    24. }
    25. }

    控制台输出

    59 60 70 80 88 45 90 100 95 96
    A:4 B:4 C:2

      1. 求1-100 的和
    1. package Weekly_Task;
    2. /**
    3. * @author Devil
    4. * @create 2021-10-24-20:35
    5. */
    6. public class Demo3 {
    7. public static void main(String[] args) {
    8. int sum = 0;
    9. for (int i = 0; i < 100; i++) {
    10. sum++;
    11. }
    12. System.out.println(sum);
    13. }
    14. }

    控制台输出

    100

    1. 定义一个数组,输入 5 个数,输出大于50的数

    例如:

    1. 输入: 40 50 45 62 50
    2. 输出: 62
    1. package Weekly_Task;
    2. import java.util.Scanner;
    3. /**
    4. * @author Devil
    5. * @create 2021-10-24-20:39
    6. */
    7. public class Demo4 {
    8. public static void main(String[] args) {
    9. Scanner input = new Scanner(System.in);
    10. int[] array = new int[4];
    11. for (int i = 0; i < 4; i++) {
    12. array[i] = input.nextInt();
    13. if(array[i]>50){
    14. System.out.print(array[i]);
    15. }
    16. }
    17. }
    18. }

    控制台输出

    40 50 45 62 50
    62