0

How do I add a While, For, or do loop to make the code continue until the user enters a sentinel value or keyword?

https://code.sololearn.com/cChcCe0KMOOs/?ref=app

7th Nov 2019, 12:55 AM
GumGumBro 901
GumGumBro 901 - avatar
2 Respostas
0
import java.util.Scanner; public class RPSTester { public static void main(String[] args) { String winner = ""; Scanner obj1 = new Scanner (System.in); System.out.println("Enter Rock, Paper or Scissors: "); String userChoice = obj1.nextLine(); if (userChoice.equalsIgnoreCase("Rock") || userChoice.equalsIgnoreCase("Paper") || userChoice.equalsIgnoreCase("Scissors")) { winner += userChoice; System.out.println(winner); } else System.out.println("Please enter a valid value"); } } Your above code atleast works now.
7th Nov 2019, 2:44 AM
Avinesh
Avinesh - avatar
0
Thanks
7th Nov 2019, 3:13 AM
GumGumBro 901
GumGumBro 901 - avatar