Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in the following Java program, why are Enter player 2's name: and Enter player 2's maxium number of steps per turn: showing up on

in the following Java program, why are "Enter player 2's name: and Enter player 2's maxium number of steps per turn: " showing up on the same line when running the program?
image text in transcribed
public class Main \{ public static void PlayGame(String playerinane, int playerlnaxsteps, String player2nane, int Random rand = new Random (); Int playeritotal =0; int player2total =0; while (playeritotal player2total) 1 Systen.out. println(playeriname + "winsi"); j else f System. out. println(player2name + "wins!"); \} 7 public static void main(String[] args) \{ Scanner 5c= new Scanner (source:Systen. in); System.out.print( " "Enter player 1 's nane: "); String playerinane =5c.nextline(); int playerlmaxsteps =sc. nextInt () ; System. out.print( st."Enter player 2's name: "); String player2name: player2nane = sc. nextLine () ; System. out. print ( si "Enter player 2 's naximun number of steps per turn: "): int p layer2maxsteps =5C. nextint () ; PlayGame(playeriname, playerinaxsteps, player2nane, player2maxsteps); 3 O PlayGame > player2total com.mycompany.main.Main itput x Run (Main) Aun (Main) cd /User5/brianchurch/NetBeansProjects/Main; JAVA_HONE=/Library/Java/JavaVirtua Wachines/jdk-19. jdik Running NetBeans Compite On Save execution. Phase execution is skipped and output directories of dep Scanning for projects... Building Main 1.6-SNAPSHOT con. myconpany:Main - exec-maven-plugin:3.0.0:exec (default-cli) Main -. Enter player 1 's nane: Joe Enter player 1 's maximun number of steps per turn: 10 Enter player 2 s nane: Enter player 2 s maximum nunber of steps per turn

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions