流程控制简单知识点以及零碎知识点

来源:互联网 发布:对冲书籍 知乎 编辑:程序博客网 时间:2024/06/05 18:31

一、选择控制:

if语句

例如:

Scanner sc=new Scanner(System.in);
  System.out.println("请输入成绩");
  int chengji=sc.nextInt();
  if(chengji>=98)
  {
   System.out.println("奖励");
  }

  if(chengji<98)
  {
   System.out.println("去吃屎");
  }

重点:

1.输入框的编写。

2.if的使用。


if-else语句

例如:

Scanner sc=new Scanner(System.in);
  System.out.println("请输入成绩");
  int chengji=sc.nextInt();
  if(chengji>=98)
  {
   System.out.println("奖励");
  }else {
   System.out.println("去吃屎");
  }


-------------------------------------------------------------

  Scanner sc=new Scanner(System.in);
  double b=sc.nextDouble();
  double suibian=4.3/3*5*b;
  System.out.println(suibian);





  
  Scanner sc=new Scanner(System.in);
  double r=sc.nextDouble();
  double t1=4/3.0*3.14*r*r*r;
  System.out.println(t1);

此为输入框的编辑代码。

-----------------------------------------------------














0 0