• 金嘉琪 1009


     1.判断计算是否正确

    import java.util.Scanner;

      public class FM
        {
          public static void main(String[] args)
            {
              int number1=(int)(System.currentTimeMillis()%10);
              int number2=(int)(System.currentTimeMillis()/7%10);

              Scanner input =new Scanner(System.in);

              System.out.print("what is " + number1 + "+" + number2 +" = ? ");
              int answer=input.nextInt();

              System.out.println(number1 + "+" + number2 + "=" + answer + " is " + (number1 + number2 == answer));

            }
        }

    2.随便写一个数字 然后判断

    import java.util.Scanner;
      public class HE
        {
          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随便生成一个计算题 然后判断错对

    import java.util.Scanner;

      public class MF 
      {
        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.print("What is " + number1 + " - " + number2 + " = ? ");
            Scanner input = new Scanner(System.in);
            int answer = input.nextInt();

            if(number1 - number2 ==answer)
            System.out.println("你对了");
            else
            {
            System.out.println("你错了");

            System.out.println(number1 + "-" + number2 +" should be " + (number1 -number2));
            }
        }
      }

    4.计算身体平衡值 看BMI值是否正常

    import java.util.Scanner;
      public class BMI 
      {
        public static void main(String[] args)
        {
          Scanner input =new Scanner(System.in);

          System.out.print("输入体重");
          double weight=input.nextDouble();

          System.out.print("输入身高");
          double height=input.nextDouble();

          double bmi=weight/(height*height);

          System.out.println("BMI is" + bmi);
          if (bmi<18.5)
          System.out.println("太瘦");
          else if (bmi<25)
          System.out.println("刚好");
          else if (bmi<30)
          System.out.println("超重");
          else 
          System.out.println("太胖");
        }
      }

  • 相关阅读:
    MathType如何插入竖直线
    MongoDB时间类型
    《穆斯林的葬礼》读书笔记
    Fluentd安装——通过rpm方式
    MongoDB安装、管理工具、操作
    Flask服务入门案例
    python判断类型
    linux硬链接与软链接
    python 环境问题
    Linux进程管理工具——supervisor
  • 原文地址:https://www.cnblogs.com/ninomiya617/p/7670733.html
Copyright © 2020-2023  润新知