I'm trying to update an array element in Java. Some sort of a database like program, but using an array to store data temporarily.
The code seems to be working only on the first array element which is 0
.
If I try to search for other records, it cannot find them. I don't know why.
boolean blnFound=false;
String strP=getString("Input product to update: ");
try{
//loop through the array
for(int a=0; a<iSl; a++){
if(strP.compareToIgnoreCase(aProd_name[a])==0){
//display information match is found
Display("Product already registered..");
Display("Product ID: ",aProd_id[a]);
Display("Product Name: ", aProd_name[a]);
Display("Product Description: ", aProd_desc[a]);
Display("Product Size: ", aSize[a]);
Display("Total Quantity: ", aTotalQty[a]);
Display("Quantity on hand: ", aQtyonHand[a]);
Display("Reorder Quantity: ", aReorder[a]);
Display("Dealer Price: ", aDPrice[a]);
Display("Selling Price: ", aSPrice[a]);
Display("Manufacture date: ", aMDate[a]);
Display("Expiry date: ", aEDate[a]);
Display("Manufacturer: ", aManufacturer[a]);
blnFound=true;
Here's the part where it updates:
//Input new information
aProd_id[a]=getInteger("Input new product id: ");
aProd_desc[a]=getString("Input new product description: ");
aSize[a]=getString("Input new size: ");
aTotalQty[a]=getDouble("Input new total quantity: ");
aQtyonHand[a]=getDouble("Input new quantity on hand: ");
aReorder[a]=getDouble("Input new reorder: ");
aDPrice[a]=getDouble("Input new dealer price: ");
aSPrice[a]=getDouble("Input new selling price: ");
aMDate[a]=getString("Input new manufactured date: ");
aEDate[a]=getString("Input new expiration date: ");
aManufacturer[a]=getString("Input new manufacturer: ");
Display("Product updated!");