• 8


    //题目3.7
    import java.util.Scanner;
    public class L {
    
        @SuppressWarnings("resource")
        public static void main(String[] args) {
                 Scanner input = new Scanner(System.in);
                System.out.print("Enter a year:");
                int year = input.nextInt();
                boolean isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
                System.out.println(year + " is a leap year?" +"
    "+ isLeapYear);
        }
    }
    
    //题目3.6
    import java.util.Scanner;
    public class L {
    
        @SuppressWarnings("resource")
        public static void main(String[] args) {
             Scanner input = new Scanner(System.in);
    
                System.out.print("Enter an integer:");
                int number = input.nextInt();
                if (number % 2 == 0 && number % 3 ==0)
                    System.out.println(number + " is divisible by 2 and 3.");
                if (number % 2 == 0 || number % 3 ==0)
                    System.out.println(number + " is divisible by 2 or 3.");
                if (number % 2 == 0 ^ number % 3 ==0)
                    System.out.println(number + " is divisible by 2 or 3, but not both.");
        }
    }
    
    // 题目3.7
    import java.util.Scanner;
    public class L {
    
        @SuppressWarnings("resource")
        public static void main(String[] args) {
                 Scanner input = new Scanner(System.in);
                System.out.print("Enter a year:");
                int year = input.nextInt();
                boolean isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
                System.out.println(year + " is a leap year?" +"
    "+ isLeapYear);
        }
    }
    //  题目3.6
    import java.util.Scanner;
    public class L {
    
        @SuppressWarnings("resource")
        public static void main(String[] args) {
             Scanner input = new Scanner(System.in);
    
                System.out.print("Enter an integer:");
                int number = input.nextInt();
                if (number % 2 == 0 && number % 3 ==0)
                    System.out.println(number + " is divisible by 2 and 3.");
                if (number % 2 == 0 || number % 3 ==0)
                    System.out.println(number + " is divisible by 2 or 3.");
                if (number % 2 == 0 ^ number % 3 ==0)
                    System.out.println(number + " is divisible by 2 or 3, but not both.");
        }
    }
    
    
     
    //题目3.4
    import java.util.Scanner;
    public class L {
    
        @SuppressWarnings("resource")
        public static void main(String[] args) {
            Scanner input = new Scanner(System.in);
    
            System.out.print("Enter weight in kilograms:");
            double weight = input.nextDouble();
    
            System.out.print("Enter height in meters:");
            double height = input.nextDouble();
    
            double bmi = weight/(height * height);
    
            System.out.println("BMI is " + bmi);
            if (bmi < 18.5)
                System.out.println("Underweight");
            else if (bmi < 25)
                System.out.println("Normal");
            else if (bmi < 30)
                System.out.println("Overweight");
            else
                System.out.println("Obese");
        }
    }
    
     
    // 题目3.3
    import java.util.Scanner;
    public class L {
    
        @SuppressWarnings("resource")
        public static void main(String[] args) {
            int number1 = (int)(Math.random() * 10);
            int number2 = (int)(Math.random() * 10);
    
            if (number1 < number2)
            {
                int temp = number1;
                number1 = number2;
                number2 = temp;
            }
            System.out.println("What is " + number1 + "-" + number2 + "?");
            Scanner input = new Scanner(System.in);
            int answer = input.nextInt();
            if (number1 - number2 == answer)
                System.out.println("You are correct!");
            else{
                System.out.println("Your answer is wrong.");
                System.out.println(number1 + "-" + number2 + "should be " + (number1-number2));
            }
        }
    }
    // 题目3.2
    import java.util.Scanner;
    public class L {
    
        @SuppressWarnings("resource")
        public static void main(String[] args) {
            Scanner input = new Scanner(System.in);
            System.out.println("Enter an integer:");
            int number = input.nextInt();
            if (number % 5 == 0)
                System.out.println("HiFive");
            if(number % 2 == 0)
                System.out.println("HiEven");
        }
    }
    
    
    // 题目3.1
    import java.util.Scanner;
    public class L {
    
        public static void main(String[] args) {
              int number1=(int)(System.currentTimeMillis()%10);
                int number2=(int)(System.currentTimeMillis()/7%10);
                @SuppressWarnings("resource")
                Scanner input=new Scanner(System.in);
                System.out.println("What is "+number1+"+"+number2+"?");
                int answer = input.nextInt();
                System.out.println(number1+"+"+number2+"="+answer+" is "+(number1+number2==answer)); 
        }
    }
  • 相关阅读:
    LoaRunner性能测试系统学习教程:场景设计实践之IP欺骗技术(2)
    LoaRunner性能测试系统学习教程:场景设计实践之集合点(1)
    LoadRunner性能测试系统学习教程:脚本编写之异步函数(9)
    LoadRunner性能测试系统学习教程:脚本编写之异步技术(8)
    LoadRunner性能测试系统学习教程:脚本编写之关联函数介绍(7)
    LoadRunner性能测试系统学习教程:脚本编写之关联技术(6)
    川石学员:毕业一年,月入过万,这你能想象?
    LoadRunner性能测试系统学习教程:脚本编写之关联技术(5)
    完整语法的增删改查
    表的详细操作、表关系
  • 原文地址:https://www.cnblogs.com/speater/p/7676621.html
Copyright © 2020-2023  润新知