Add to Chrome
✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Which of these programs can display what the user enters on the keyboard until the user enters the word: ok?
Scanner sc = new Scanner(System.in); String s = ""; while(s.compareTo("ok") == 0) { s = sc.nextLine(); System.out.println(s); }
Scanner sc = new Scanner(System.in); String s = ""; while(s.compareTo("ok") != 0) { s = sc.nextLine(); System.out.println(s); }
Scanner sc = new Scanner(System.in); String s = ""; while(sc.hasNext()) { if (s.compareTo("ok") != 0) { s = sc.nextLine(); System.out.println(s); } }
if (s.compareTo("ok") != 0)
{
s = sc.nextLine();
}
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!