Java Summary for Week 2

Simulate bank ATM system, use switch to complete

 

import java.util.Scanner;
public class 类名  public static void main(String[] args) {

  // TODO Auto-generated method stub        Scanner input=new Scanner(System.in);

        System.out.println("************************************");
        System.out.println ("---------Welcome to XXX Bank ATM System---------");
        System.out.println("************** ********************");
        System.out.println("Please select the function you need: ");
        System.out.println(" 1. Account opening\n 2. Check balance\n 3. Deposit\n 4. Withdrawal\n 5. Change password\n 6. Exit\n");
        System.out.println("Please input: ");
        int number = input .nextInt();
        switch(number){
              case 1:
               System.out.println("You have chosen the account opening function, please enter your personal information");
               break;
              case 2:
               System.out.println("You have chosen For balance inquiry function, please enter your account and password");
               break;
              case 3:
               System.out.println("You have selected the deposit function, please enter your account and password");
               break;                       
              case 4:
               System.out.println("You have selected the withdrawal function, please enter your account and password") ;
               break;       
              case 5:
               System.out.println("You have selected the password change function, please enter your password");
               break;       
              case 6:
               System.out.println("Are you sure you want to exit? y/n" );       
                  String da=input.next();
                  if(da.equals("y")){
                   System.exit(0);
                  }else {
                   System.out.println("Please re-enter");
                  }
               break;
              default:
               System.out.println("Please make the correct choice");       
        }
 }

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324500399&siteId=291194637