final static int arrayLength = 1000; //maximum array size
static float[] productPrice = new float[arrayLength]; //stores the prices of products
static String[] productName = new String[arrayLength]; //stores the names of products
public static void main(String[] args) {
boolean quit = false;
do {
System.out.print("enter product: ");
String product = keyboard.nextLine();;
for(int i=0; i<productName.length; i++)
productName[i] = product;
System.out.print("enter price: ");
float price = keyboard.nextFloat();
for(int i=0; i<productPrice.length; i++)
productPrice[i] = price;
if(price == -1)
quit = true;
} while(!quit);
for(int i=0; i<productPrice.length; i++)
if(productPrice[i] > productPrice[i+1]) {
float temp = productPrice[i+1];
productPrice[i+1] = productPrice[i];
productPrice[i] = temp;
System.out.println("Product: " + productName[i] + "\nPrice: " + productPrice[i]);
}
}
How do you continue the loop? and i need to keep it going until i press -1 to stop? i need help fuiguring out this part of the statement please state your possible answers and reason why my loop is not continous and how i can make it keep gpoing and what staement i can use to stop it