Java_if else


import java.util.Scanner;
public class Look{
public static void main(String[] agrs){
    String id = "",pwd = "",id2 ="admin",pwd2="343ds...";
    int a,b,c,max;
    Scanner input = new Scanner(System.in);
    while(true){//死循環,使軟件達到可重復執行的目的
    System.out.print("請輸入您的賬號:");//先輸入賬號,判斷賬號是否正確,如果正確再進行輸入密碼.否則提示賬號錯誤!
    id = input.next();
    if(id.equals(id2)){//java判斷字符串的方法為str1.equals(str2)來比對字符串的值是否相等
        System.out.print("請輸入您的密碼:");
        pwd=input.next();
        if(pwd.equals(pwd2)){
        System.out.println("登錄成功!");//密碼輸入正確時,提示登錄成功,並且在此作用域內進行運算!
            System.out.println("請您輸入第1個數:");
            a=input.nextInt();
            System.out.println("請您輸入第2個數:");
            b=input.nextInt();
            System.out.println("請您輸入第3個數:");
            c=input.nextInt();
            if(a>b){
                      max=a;
                       }else{
                       max=b;
                              }
            if(max>b){
                     max=max;
                        }else{
                        max=c;
                                }
                System.out.println("最大值為:"+max);
        }else{
        System.out.println("密碼輸入錯誤!");
        }




    }else{
        System.out.println("您輸入的賬號錯誤!請重新輸入!");

        }


}



}
}

和C語言基本一致


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM