please solve it in java

Community Answer

【General guidance】The answer provided below has been developed in a clear step by step manner.Step1/2Dear student, here is your self written solution, Do provide UPVOTE!Solution :Here is the require a code in java:public class BasketballShootoutGame { private static final int NUM_ATTEMPTS = 3; // number of attempts per player private static final double TICKET_PER_TIE = 0.5; // half a ticket for every tie private int player1Score; private int player2Score; private int numTies; public BasketballShootoutGame() { this.player1Score = 0; this.player2Score = 0; this.numTies = 0; } public void play() { // player 1 shoots first for (int i = 0; i < NUM_ATTEMPTS; i++) { boolean basketMade = shootBasket(); if (basketMade) { player1Score++; } } // player 2 shoots second for (int i = 0; i < NUM_ATTEMPTS; i++) { boolean basketMade = shootBasket(); if (basketMade) { player2Score++; } } // check winner and update scores if (player1Score > player2Score) { // player 1 wins long numTickets = Math.round(player1Score - player2Score + numTies * TICKET_PER_TIE); System.out.println("Player 1 wins! Owed " + numTickets + " movie ticket(s)."); player1Score = 0; player2Score = 0; numTies = 0; } else if (player2Score > player1Score) { // player 2 wins long numTickets = Math.round(player2Score - player1Score + numTies * TICKET_PER_TIE); System.out.println("Player 2 wins! Owed " + numTickets + " movie ticket(s)."); player1Score = 0; player2Score = 0; numTies = 0; } else { // tie game, increment tie counter numTies++; System.out.println("Tie game!"); } } private boolean shootBasket() { // simulate a random chance of making a basket double probability = 0.5; // 50% chance of making a basket return Math.random() < probability; } public static void main(String[] args) { BasketballShootoutGame game = new BasketballShootoutGame(); int numGames = 3; // play 3 games ... See the full answer