Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I tried this, but it\'s not working. J LllUWU an example of interaction with the

ID: 3849584 • Letter: I

Question

I tried this, but it's not working.

J LllUWU an example of interaction with the program. Code Listing 4-5 (Soccer Teams. java) 1 import javax. Joption Pane; swing. This program calculates the number of soccer teams that a youth league may create from the number of available players Input validation is demonstrated with while loops. 10 public class SoccerTeams 11 12 public static void main (String[ args) final int MIN PLAYERS 9: Minimum players per team final int MAX PLAYERS 15 Maximum players per team 15 Number of available players int players 16 Number of players per team int team size; 17 Number of teams int teams 18

Explanation / Answer

Java running code:

create file named SoccerTeams.java and paste given code into it!

import javax.swing.JOptionPane;

public class SoccerTeams
{

public static void main(String[] args)
{
final int MIN_PLAYERS = 9;
final int MAX_PLAYERS = 15;
int players;
int teamSize;
int teams;
int leftOver;
String input;
  
input = JOptionPane.showInputDialog("Enter the number of " + "players per team.");
teamSize = Integer.parseInt(input);
while(teamSize < MIN_PLAYERS || teamSize > MAX_PLAYERS )
{
input = JOptionPane.showInputDialog("The number must be atleast " + MIN_PLAYERS + " and no more than " + MAX_PLAYERS + ". Enter the number of players.");
teamSize = Integer.parseInt(input);
}
input = JOptionPane.showInputDialog("Enter the available " + "number of players.");
players = Integer.parseInt(input);
  
while(players < 0 )
{
input = JOptionPane.showInputDialog("Enter 0 or greater.");
players = Integer.parseInt(input);
}
teams = players/teamSize;
leftOver = players%teamSize;
JOptionPane.showMessageDialog(null,"There will be " + teams + " teams with " + leftOver + " players left over!");
}
}