首页 > 代码库 > 课堂复习内容(1)

课堂复习内容(1)

        扫描仪类:

               import java.util.Scanner;

              Scanner input=new Scanner(System.in);

        示例:   

                import java.util.Scanner;

                 public class Test02 {
                   public static void main(String[] args) {
                    Scanner input = new Scanner(System.in);
                   System.out.println("请输入名字:");
                   String name = input.next();
                   System.out.println("请输入年龄:");
                   int age = input.nextInt();
                   System.out.println("请输入性别:");
                  char gehder = input.next().charAt(0);

                   }
               }

                  获得4位数各位
                    int custNo = input.nextInt();
                   int gewei = custNo % 10;
                  int shiwei = custNo / 10 % 10;
                  int baiwei = custNo / 100 % 10;
                   int qianwei = custNo / 1000;

  

 

课堂复习内容(1)