总结:请给我更好的建议
package com.badu;import java.util.Scanner;//从键盘输入次数,通过输入的编号,输出对应的的商品价格;public class tqwe { public static void main(String[] args) { Scanner c = new Scanner(System.in); int x = c.nextInt();// x是次数,number是编号,price是价格 int number[] = new int[x]; double price; for (int i = 0; i < x; i++) { System.out.println("请输入编号:"); number[i] = c.nextInt(); if (number[i] == 1) { price = 3.0; System.out.println("apples的价格是" + price); } else if (number[i] == 2) { price = 2.5; System.out.println("orange的价格是" + price); } else if (number[i] == 3) { price = 4.1; System.out.println("pears的价格是" + price); } else if (number[i] == 4) { price = 10.2; System.out.println("graps的价格是" + price); } else { System.out.println("该商品不存在!!!!"); continue; } } }}//6请输入编号:5该商品不存在!!!!请输入编号:3pears的价格是4.1请输入编号:2orange的价格是2.5请输入编号:1apples的价格是3.0请输入编号:3pears的价格是4.1请输入编号:4graps的价格是10.2