首页 > 代码库 > Array数组基本案例:图书基本录入输出系统

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     }    

 

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