scannerdemo.java

来自「java编程代码」· Java 代码 · 共 23 行

JAVA
23
字号

import java.util.Scanner;

public class ScannerDemo
{
   public static void main(String[] args)
   {
      Scanner keyboard = new Scanner(System.in);

      System.out.println("Enter the number of pods followed by");
      System.out.println("the number of peas in a pod:");
      int numberOfPods = keyboard.nextInt( );
      int peasPerPod = keyboard.nextInt( );

      int totalNumberOfPeas = numberOfPods*peasPerPod;

      System.out.print(numberOfPods + " pods and ");
      System.out.println(peasPerPod + " peas per pod.");
      System.out.println("The total number of peas = " 
                                          + totalNumberOfPeas);
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?