how can i sort the itemArray along with its price? because i have a problem that if i sort the items it will be sorted alphabetically but the price wont go along with the item.
public class finalsProj{
static Scanner in = new Scanner(System.in);
static Scanner in2 = new Scanner(System.in);
static Scanner in3 = new Scanner(System.in);
static int itemsInv=0;
static int price=0;
static char NO = 'N';
static String[] itemArray;
static String[] priceArray;
public static void main(String[]args){
do{
System.out.print("Input the number of items: ");
itemsInv = in.nextInt();
if(itemsInv>0){
System.out.print("Input N to change the number Y to Continue : ");
NO = in.next().toUpperCase().charAt(0);
}
}while(NO == 'N' || NO == 'n');
if(NO == 'Y'){
itemArray = new String[itemsInv];
priceArray = new String[itemsInv];
}
for(int i = 0; i < itemArray.length; i++){
System.out.print("Enter the name of item " + (i+1) + " : ");
itemArray[i] = in2.nextLine();
do{
System.out.print("Price: ");
priceArray[i] = in3.nextLine();
if(priceArray[i] < 0){
System.out.println("Input must be a VALID number");
}
}while(priceArray[i] < 0);
}
System.out.println("---------------------------------------------");
System.out.println("Items Available: " + "\nItem Name\tItem Price");
for(int i = 0; i < itemArray.length; i++){
System.out.println(itemArray[i] + "\t\t" + 'P' + priceArray[i]);
}
System.out.println("---------------------------------------------");
}
}
the output is my problem on this 1