Could you help me please with this code, I do not finish understanding why you give me this error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at com.company.Main.main(Main.java:64)
Apart from that if you can help me by giving me some ideas on how to finish it because I do not understand how to do it well. Thank you very much!
These are the slogans:
Exercise 2: Survey Load Write a function that asks the user the rating of 6 different attractions of the park denominated: A1, A2, A3, A4 and A5. The ratings go from 1 to 10 (1 is terrible and 10 is excellent or unbeatable). The aspects are: • Degree of Fun: is the fun or boring attraction. • Quality of Attraction: Attraction includes features that highlight it: lights, colors, etc. • Justice of the price: it is the cost of entry to the fair attraction. • Attention of the employees: The personnel that is found in the attraction is friendly. Request the qualifications to user and then print the average rating of each of the different attractions.
int quiz[]= new int[4], total[]= new int[6], fnl;
for(int i=0; i<6; i++) {
System.out.println("Atraccion A"+ (i+1) + ":");
for (int x=0; x<4; x++) {
if (x == 0) {
System.out.println("•\tGrado de Diversión: es la atracción divertida o aburrida.");
quiz[x] = sc.nextInt();
} else if (x == 1) {
System.out.println("•\tCalidad de la Atracción: La atracción incluye características que la resaltan: luces, colores, etc.");
quiz[x] = sc.nextInt();
} else if (x == 2) {
System.out.println("•\tJusticia del precio: es el costo de entrada a la atracción justo.");
quiz[x] = sc.nextInt();
} else if (x == 3) {
System.out.println("•\tAtención de los empleados: El personal que se encuentra en la atracción es amigable.");
quiz[x] = sc.nextInt();
}
}
total[i] = quiz[i]+total[i];
total[i]= total[i]/4;
}