zoukankan      html  css  js  c++  java
  • 第五次作业10/09

    /*程序员:张立平

    需求1:自动生成计算题并判断答案正误
    */
     
    import java.util.Scanner;
    public class  Z
    {   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
        }
    }



    /*程序员:张立平

    需求2:自动生成计算题并判断答案正误
    */
     
    import java.util.Scanner;
    public class  Z
    {   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  Z
    {   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.Scannerpublic class  Z{  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("超重");
      
     
      }
    }


  • 相关阅读:
    【Java】Caused by: com.ibatis.sqlmap.client.SqlMapException: There is no statement named *** in this SqlMap.
    【Mac】Mac 使用 zsh 后, mvn 命令无效
    【Java】Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 1099
    【Android】drawable VS mipmap
    【Android】java.lang.SecurityException: getDeviceId: Neither user 10065 nor current process has android.permission.READ_PHONE_STATE
    java sql解析
    java动态编译
    随想
    一致hash算法
    一致性哈希算法及其在分布式系统中的应用
  • 原文地址:https://www.cnblogs.com/zhangliping123/p/7704901.html
Copyright © 2011-2022 走看看