rendered paste body public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int[] rows = {1, 2, 3, 4, 5};
int rowToRemove, amountToRemove;
int count = 1;
int sum = 0;
for (int i = 0; i < rows.length; i++) { sum += rows[i]; }
while(sum > 0)
{
count++;
for (int i = 0; i < rows.length; i++)
{
System.out.print("\n" + (i + 1) + ": ");
for (int j = 0; j < rows[i]; j++) { System.out.print("|"); }
}
System.out.println("\nPlayer " + (count % 2 == 0 ? 'A' : 'B') + ": Which row do you want to remove from?");
rowToRemove = scan.nextInt();
System.out.println("\nPlayer " + (count % 2 == 0 ? 'A' : 'B') + ": How many items do you want to remove?");
amountToRemove = scan.nextInt();
rows[rowToRemove - 1] -= amountToRemove;
sum = 0;
for (int i = 0; i < rows.length; i++) { sum += rows[i]; }
}
System.out.println("Player " + (count % 2 == 0 ? 'A' : 'B') + " wins!");
}