#why does the loop not work
9 messages ยท Page 1 of 1 (latest)
โ This post has been reserved for your question.
Hey @hasty patio! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Please format your code to make it more readable.
For java, it should look like this:
```โโโ`โjava
public void foo() {
}
โโโ`โ```
class HelloWorld {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String allPlayers = " ";
String allPlayers2 = " ";
int round = 0;
System.out.println("Welcome to the Fantasy draft. There weill be 2 players, player 1 and player 2.");
while(round <= 5)
round = round + 1;
System.out.println("It is player 1's turn. Who will you select?");
String playerFirstName = scanner.next();
String playerSecondName = scanner.next();
String playerFullName = playerFirstName + " " + playerSecondName;
if (allPlayers == " " ){
allPlayers = playerFullName;
System.out.println("Here are player 1's players");
System.out.println(allPlayers);
}
else {
allPlayers = allPlayers + "," + playerFullName;
System.out.println("Here are player 1's players");
System.out.println(allPlayers);
}
System.out.println("It is player 2's turn. Who will you select?");
String playerFirstName2 = scanner.next();
String playerSecondName2 = scanner.next();
String playerFullName2 = playerFirstName2 + " " + playerSecondName2;
if (allPlayers2 == " " ){
allPlayers2 = playerFullName2;
System.out.println("Here are player 2's players");
System.out.println(allPlayers2);
}
else {
allPlayers2 = allPlayers2 + "," + playerFullName2;
System.out.println("Here are player 2's players");
System.out.println(allPlayers2);
}
}
}
why does the loop not work
Nevermind, i got it ๐ญ
thanks
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.