Final answer:
To print a table with a list of at least 5 band's attendances and their total attendance in Java, you can use a combination of arrays and loops.
Step-by-step explanation:
To print a table with a list of at least 5 band's attendances and their total attendance in Java, you can use a combination of arrays and loops. Here is an example program:
public class BandAttendance {
public static void main(String[] args) {
String[] bands = {"Band A", "Band B", "Band C", "Band D", "Band E"};
int[][] attendance = {{100, 150}, {200, 100}, {300, 200}, {250, 300}, {150, 150}};
System.out.println("Bands Attendance Table");
System.out.println("---------------------");
System.out.println("Band\tVenue 1\tVenue 2\tTotal Attendance");
for (int i = 0; i < bands.length; i++) {
int totalAttendance = attendance[i][0] + attendance[i][1];
System.out.println(bands[i] + "\t" + attendance[i][0] + "\t" + attendance[i][1] + "\t" + totalAttendance);
}
}
}
This program creates two arrays: one for the band names and another for the attendance numbers. It then uses a for loop to iterate over the arrays and calculate the total attendance for each band. The table is printed using the System.out.println() method.