I've been trying to make a program that will just write 2D arrays with the following text through print format. The output I am expecting supposedly should look like this, don't mind the bold points they are meant for new line:
Name : Florence
Tel. # : 735-1234
Address: Chicago
*
Name : Joyce
Tel. # : 983-3333
Address: Evanston
*
Name : Becca
Tel. # : 456-3322
Address: Oak Park
This is my code so far:
public static void main(String[] args) {
String[][] entry = {
{"Florence", "735-1234", "Chicago"},
{"Joyce", "983-3333", "Evanston"},
{"Becca", "456-3322", "Oak Park"}};
for (int i = 0; i < entry.length; i++) {
for (int q = 0; q < entry[i].length; q++) {
System.out.printf("\n%s\n%s\n%s",
"Name : " + entry[i][q],
"Tel. # : " + entry[i][q],
"Address: " + entry[i][q]);
}
System.out.println();
}
}
But my output only shows this:
*
Name : Florence
Tel. # : Florence
Address: Florence
Name : 735-1234
Tel. # : 735-1234
Address: 735-1234
Name : Chicago
Tel. # : Chicago
Address: Chicago
*
Name : Joyce
Tel. # : Joyce
Address: Joyce
Name : 983-3333
Tel. # : 983-3333
Address: 983-3333
Name : Evanston
Tel. # : Evanston
Address: Evanston
*
Name : Becca
Tel. # : Becca
Address: Becca
Name : 456-3322
Tel. # : 456-3322
Address: 456-3322
Name : Oak Park
Tel. # : Oak Park
Address: Oak Park
Any tip or advice will be greatly appreciated.