Untitled
unknown
plain_text
2 years ago
1.0 kB
9
Indexable
import java.util.Scanner;
public class EventAttendance {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the total number of people attending the event: ");
int totalAttendees = scanner.nextInt();
System.out.print("Enter the number of groups: ");
int numGroups = scanner.nextInt();
int[] groupSizes = new int[numGroups];
for (int i = 0; i < numGroups; i++) {
System.out.print("Enter the size of group " + (i + 1) + ": ");
groupSizes[i] = scanner.nextInt();
}
System.out.println("Total Attendees: " + totalAttendees);
System.out.println("Number of Groups: " + numGroups);
System.out.println("Group sizes:");
for (int i = 0; i < numGroups; i++) {
System.out.println("Group " + (i + 1) + ": " + groupSizes[i]);
}
scanner.close();
}
}Editor is loading...