3.26课上练习1802王兆明

package hm;
//第一题
import java.util.Scanner;

public class classPractice3_26_01 {
public static void main(String[] args) {
    Scanner sca = new  Scanner(System.in);
        int a = 0;
    while(true){
        System.out.println("输入一个值");
        a = sca.nextInt();
        if(a==1){
            System.out.println(a);
        }else if(a==5){
            System.out.println(a);
        }else if (a==10) {
            System.out.println(a);
        }else{
            System.out.println("none");
        }
        
    }
}
}
package hm;

import java.util.Scanner;
//第二题
public class classPractice3_26_02 {

    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        System.out.println("输入一个数字");
        int a = sca.nextInt();
        switch (a) {
        case 1:
            System.out.println(a);
            break;
        case 5:
            System.out.println(a);
            break;
        case 10:
            System.out.println(a);
            break;

        default:
            System.out.println("none");
            break;
        }
    }

}
package hm;

import java.util.Scanner;
//第三题
public class classPractice3_26_03 {

    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        System.out.println("输入一个数字");
        int a = sca.nextInt();
        if (a%5==0&&a%6==0) {
            System.out.println("这个数字可以被56整除");
        }else if(a%5==0){
            System.out.println("这个数可以被5整除");
        }else if(a%6==0){
            System.out.println("这个数可以被6整除");
        }else{
            System.out.println("这个数不能被5和6整除");
        }
    }

}
package hm;

import java.util.Scanner;
//第四题
public class classPractice3_26_04 {

    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        System.out.println("输入1-100之间的分数");
        int a = sca.nextInt();
        switch (a/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("不及格");
            break;
        
        default:
            System.out.println("输入有误");
            break;
        }
    }

}
package hm;

import java.util.Scanner;
//第五题
public class classPractice3_26_05 {

    public static void main(String[] args) {
        Scanner sca  = new Scanner(System.in);
        System.out.println("输入三个数");
                int  a = sca.nextInt();
                int  b = sca.nextInt();
                int  c = sca.nextInt();
                if(a>b){
                    if(b>c){
                        System.out.println(a+","+b+","+c);
                    }else if(a<c){
                        System.out.println(c+","+a+","+b);
                    }else{
                        System.out.println(a+","+c+","+b);
    
                    }
                }else if(b>a){
                    if(a>c){
                        System.out.println(b+","+a+","+c);
                    }else if(b<c){
                        System.out.println(c+","+b+","+a);
                    }else{
                        System.out.println(b+","+c+","+a);

                    }
                }
    }

}

 

posted @ 2020-03-26 11:45  计算机1802王兆明  阅读(139)  评论(0编辑  收藏  举报