//different types of items purchased
System.out.print("How many different types of items are being purchased? " );
ArraySize = input.nextInt();
input.nextLine();
//arrays - being defined after ArraySize
String[] item = new String[ArraySize]; //each item
int[] itemsPurchased = new int[ArraySize]; //item purchased
double[] price = new double[ArraySize]; //price for each 'line' on the receipt
double[] itemPrice = new double[ArraySize]; //price of item purchased
for (int i=0; i<ArraySize; i++){ //i = variable element counter
//name of item purchased
System.out.print("Item purchased: ");
item[i] = input.nextLine();
//number of items purchased
System.out.print("Quantity: ");
itemsPurchased[i] = input.nextInt();
input.nextLine();
//determines price of item based on what was purchased
if (item.equals("Shoes") || item.equals("shoes") || item.equals("SHOES"))
itemPrice[i] = 50.00;
if (item.equals("T-Shirt") || item.equals("t-shirt") || (item.equals("T-SHIRT")))
itemPrice[i] = 40.00;
if (item.equals("Shorts") || item.equals("shorts") || item.equals("SHORTS"))
itemPrice[i] = 75.00;
if (item.equals("Cap") || item.equals("cap") || item.equals("CAP"))
itemPrice[i] = 20.00;
if (item.equals("Jacket") || item.equals("jacket") || item.equals("JACKET"))
itemPrice[i] = 100.00;
//adds item and item amount
price[i] += (itemsPurchased[i] * itemPrice[i]);
}//end for
我正在尝试制作看起来像的收据行
项目 ---------- 数量 ------------成本
项目 ---------- 数量 ------------成本
项目 ---------- 数量 ------------成本
但是我坐起来保存成本的那一行(我链接的最后一行)在第一个元素之后没有保存任何东西。我只链接了我认为相关的内容,如果需要,我可以提供其余代码。