I would like to create a shopping list program, after entering the name and price of product enters them into the arrays and then print the entire list of what is wrong with this code?
import java.util.Scanner;
import java.util.Arrays;
public class List {
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
String [] name = new String[4];
double [] price = new double[4];
for (int i =0; i<name.length; i++) {
System.out.println("name");
name[i] = sc.nextLine();
System.out.println("price");
price[i] = sc.nextDouble();
}
System.out.println("your product: " + Arrays.toString(name) + Arrays.toString(price));
}
}