码迷,mamicode.com
首页 > 其他好文 > 详细

3.26课上练习1802王兆明

时间:2020-03-26 12:24:44      阅读:78      评论:0      收藏:0      [点我收藏+]

标签:div   ack   print   ati   string   ice   static   rgs   int()   

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);

                    }
                }
    }

}

 

3.26课上练习1802王兆明

标签:div   ack   print   ati   string   ice   static   rgs   int()   

原文地址:https://www.cnblogs.com/wzm7282/p/12573247.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!