好了,所以我只能通过我的数组库存计划的方式组成部分,但应该提示用户重新输入号码时,他们已经进入了一个无效将不执行我的while循环。 当输入程序为无效号码刚刚结束......我曾尝试一些方法,也不是工作。 这就是我在现在,任何想法?
非常感谢!
public class InventorySystem {
public static void main(String[] args) {
String[] newItemInfo = new String[1000];
String[] itemDescription = new String[1000];
int[] itemPrice = new int[1000];
int choice;
boolean isValid;
int itemChoice;
Scanner inputDevice = new Scanner(System.in);
System.out.println("*****Raider Inventory System*****");
System.out.println("1. Enter a new item");
System.out.println("2. View Item Information");
System.out.println("3. View a list of all items");
System.out.println("9. End Program\n");
System.out.println("Please enter your selection: ");
choice = inputDevice.nextInt();
if (choice == 1 || choice == 2 || choice == 3 || choice == 9) {
isValid = true;
} else {
isValid = false;
}
** while (isValid = false) {
System.out.println("Invalid entry, please enter either 1, 2, 3, or 9 for menu options.");
** }
for (int x = 0; x < 1000; ++x) {
if (choice == 1) {
System.out.println("Please enter the name if the item: ");
newItemInfo[x] = inputDevice.nextLine();
System.out.println("Please enter the item description: ");
itemDescription[x] = inputDevice.nextLine();
System.out.println("Please enter item price: ");
itemPrice[x] = inputDevice.nextInt();
}
}
if (choice == 2) {
System.out.println("***Show item Description***");
System.out.println("0. ");
System.out.println("please enter the item number ot view details: ");
itemChoice = inputDevice.nextInt();
}
if (choice == 3) {
System.out.println("****Item List Report****");
}
if (choice == 9) {
System.exit(0);
}
}
}