Question: How Many Players You have been provided with a Stringvariable called sport and an int variable called players. Write a switch statement that will reassignthe
How Many Players
You have been provided with a Stringvariable called sport and an int variable called players.
Write a switch statement that will reassignthe value of players based on the sportprovided. The sport input can be either uppercase or lowercase, so please keep this in mind when writing your code.
The following sports should be considered along with the corresponding number of players:
Soccer players
Basketball players
Baseball players
Hockey players
Tennis player
If the sport variable matches one of the sports listed above, reassign players to the corresponding number of players. You do not need to print or return any code. The print statements are provided for you.
If the sport variable does not match any of the listed sports, use the default case to reassign players to the value
import java.util.;
public class SportsPlayers
public static void mainString args
Scanner input new ScannerSystemin;
String sport input.nextLine;
int players ;
DO NOT CHANGE THE CODE ABOVE THIS LINE
WRITE SWITCH STATEMENT HERE
DO NOT CHANGE THE CODE BELOW THIS LINE
if players
System.out.printlnUnknown sport";
else
System.out.printlnIn sport there are players players on each team.";
STDOUT
Expected STDOUT
Insoccerthereareplayersoneachteam
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
