I have to make a program in which I use two-dimensional arrays.
The problem is like this: Program that gives the option of entering 5 names and 5 types of fruits in a two-dimensional matrix and at the end that the option appears to the user of choice "What do you want to show: the names or fruits entered ? " and print. Either switch option or with for.
I am a beginner and this is my wrong approach.
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Opt {
public static void main(String[] args) {
String [][] matriz= new String [2][5];
Scanner scan= new Scanner (System.in);
System.out.println ("Introduzca nombre");
for (int i=0; i<=3; i++){
System.out.println (" ");
for (int j=0; j<=5; j++){
matriz [i] [j] = scan.NextLine();
}
System.out.println ("Introduzca fruta");
for (int i1=0; i1<=3; i1++){
System.out.println (" ");
for (int j=0; j<=5; j++){
Object [] frutas;
matriz [i] [j]= scan.NextLine;
System.out.println ("QUE QUIERES QUE TE MUESTRE LOS NOMBRES O FRUTAS INGRESADOS");
}
}
}
}