zoukankan      html  css  js  c++  java
  • 第三章 选择结构(一)

    if选择结构        示例1:           import java.util.Scanner;

                                                     public class GetPrize{

                                            public static void main(String [ ] args){

                                                    Scanner input=new Scanner(System.in);

                                                  System.out.print("输入张浩的Java成绩");

                                               int score=input.nextInt();

                                                             if(score>98){

                                                       System.out.println("老师说:不错奖励一个mp4!");

                                                                 }

                                                          }

                                                 }

                                          

                         

    复杂结构下的if选择结构:   &&(与、并且)       条件1&&条件2

                                       ||(或、或者)        条件1||条件2

                                       i(非)                      !条件

    示例2:            pulic class GetPrize2{

                                                    public static void main(String[]args){

                                                          int score1=100;

                                                          int score2=72;

                                              if((score1>98&&score2>80)||(score1==100&&score2>70)){

                                                        System.out.println("老师说:不错,奖励一个MP4!");             

                                                         }

                                                     }

                                               }

                                              

                            语法:                 if(条件){

                                                             代码块1

                                                       }else{

                                                             代码块2

                                                      }

                                              public class SimpleIf2{

                                        public static void main(String[]args){

                                                          int score=91;

                                                if(score>98){

                                                      System.out.println("MP4一个!");

                                                }else{

                                                         System.out.println("惩罚进行编码!");

                                                   }

                                               } 

                                                   }

  • 相关阅读:
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    Security and Cryptography in Python
    微信小程序TodoList
    C语言88案例-找出数列中的最大值和最小值
    C语言88案例-使用指针的指针输出字符串
  • 原文地址:https://www.cnblogs.com/justinbieber/p/6684829.html
Copyright © 2011-2022 走看看