Array数组基本案例:图书基本录入输出系统

 1 import java.util.Scanner;
 2 
 3 public class ArrayTest{
 4     public static void main(String args[]){
 5         Scanner sc = new Scanner(System.in);
 6         String[] book = new String[3];
 7         String[] bookNum = new String[3];
 8         int[] bookPrice = new int[3];
 9         for(int i = 0; i< book.length; i++){
10             System.out.println("请输入第"+(i+1) +"本书的书名:");
11             book[i] = sc.next();
12             System.out.println("请输入第"+(i+1) +"本书的编号:");
13             bookNum[i] = sc.next();
14             System.out.println("请输入第"+(i+1) +"本书的价格:");
15             bookPrice[i] = sc.nextInt();
16         }
17         System.out.print("书名\t编号\t价格\n");
18         for(int j = 0; j < book.length;j++){
19             System.out.print(book[j]+"\t"+bookNum[j]+"\t"+bookPrice[j]+"\n");
20         }
21         }
22     }    

 

posted @ 2016-11-16 11:42  cheney-yang  阅读(307)  评论(0编辑  收藏  举报