• 第四周上机练习


    package test;
    import java.util.Scanner;
    public class LH {
    
        public static void main(String[] args) {
            System.out.println("请输入一个值x");
            Scanner input=new Scanner(System.in);
            int x=input.nextInt();
            if(x==1){
                System.out.println("x=1");
            }else if(x==5){
                System.out.println("x=5");
            }else if(x==10){
                System.out.println("x=10");
            }else{
                System.out.println("none");
            }
        }
    }

    2.

    package test;
    import java.util.Scanner;
    public class LH {
    
        public static void main(String[] args) {
            System.out.println("请输入一个值x");
            Scanner input=new Scanner(System.in);
            int x=input.nextInt();
            switch(x){
            case 1:
                System.out.println("x=1");
            break;
            case 5:
                System.out.println("x=5");
            break;
            case 10:
                System.out.println("x=10");
            break;
            default:
                System.out.println("none");
            }
        }
    }

    3.

    package test;
    import java.util.Scanner;
    public class LH {
    
        public static void main(String[] args) {
            System.out.println("请输入一个值x");
            Scanner input=new Scanner(System.in);
            int x=input.nextInt();
            if(x%5==0&&x%6==0){
                System.out.println(x+"能被5和6同时整除");
            }else if(x%5==0&&x%6!=0){
                System.out.println(x+"只能被5整除");
            }else if(x%5!=0&&x%6==0){
                System.out.println(x+"只能被6整除");
            }else if(x%5!=0&&x%6!=0){
                System.out.println(x+"不能被5或6整除");
            }
        }
    }

    4.

    package test;
    import java.util.Scanner;
    import java.util.concurrent.SynchronousQueue;
    public class LH {
    
        public static void main(String[] args) {
            System.out.println("请输入一个0到100的分数");
            Scanner input=new Scanner(System.in);
            int x=input.nextInt();
            if(x>=90){
                System.out.println("A");
            }else if(x>=80){
                System.out.println("B");
            }else if(x>=70){
                System.out.println("C");
            }else if(x>=60){
                System.out.println("D");
            }else if(x>=50){
                System.out.println("E");
            }else{
                System.out.println("F");
            }
        }
    }

    5.

    package test;
    import java.util.Scanner;
    import java.util.concurrent.SynchronousQueue;
    public class LH {
    
        public static void main(String[] args) {
            System.out.println("请输入三个数");
            Scanner input=new Scanner(System.in);
            int x=input.nextInt();
            int y=input.nextInt();
            int z=input.nextInt();
            int d;
            if (x>y){
                d=x;
                x=y;
                y=d;
                }
            if (x>z){
                d=x;
                x=z;
                z=d;
                }
            if (y>z){
                d=y;
                y=z;
                z=d;
                }
            System.out.println("三个数从小到大的顺序是"+x+y+z);
            }
        }
  • 相关阅读:
    SpringBoot学习
    Matlab立体标定mat转换成Opencv的CvMat
    由lib引发的血案(opencv找不函数问题)
    C# 使用Epplus导出Excel [4]:合并指定行
    C# 使用Epplus导出Excel [3]:合并列连续相同数据
    C# 使用Epplus导出Excel [2]:导出动态列数据
    C# 使用Epplus导出Excel [1]:导出固定列数据
    C# Excel常用控件总结
    C# IsNullOrEmpty与IsNullOrWhiteSpace
    C# 读App.config配置文件[2]: .Net Core框架
  • 原文地址:https://www.cnblogs.com/z118127/p/12573835.html
Copyright © 2020-2023  润新知