Knowee
Questions
Features
Study Tools

Which of the following will loop until the user enters a value for String for str2 that does NOT match str1?  (Mark ALL that apply)Scanner input = new Scanner(System.in);String str1 = input.nextLine();String str2 = input.nextLine();while ( CONDITION ) { str2 = input.nextLine();}

Question

Which of the following will loop until the user enters a value for String for str2 that does NOT match str1?  (Mark ALL that apply)Scanner input = new Scanner(System.in);String str1 = input.nextLine();String str2 = input.nextLine();while ( CONDITION ) { str2 = input.nextLine();}

🧐 Not the exact question you are looking for?Go ask a question

Solution

The condition that will make the loop continue until the user enters a value for str2 that does not match str1 is:

while (str1.equals(str2))

This condition checks if str1 is equal to str2. If they are equal, the loop will continue. If they are not equal, the loop will stop.

Similar Questions

Fill the below code to compare two strings and print "yes" if they are same else print "no".Don't consider the case. Example, if the strings are  "Good" and "good" the output  should be "yes".Code :                Scanner sc=new Scanner(System.in); String s1=sc.next(); String s2=sc.next(); if()                         System.out.println("yes");                else                  System.out.println("no");

import java.io.*;import java.util.*;public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int Myint = scanner.nextInt(); double d = scanner.nextDouble(); scanner.nextLine(); String mystring = scanner.nextLine(); System.out.println(mystring); System.out.println(d); System.out.println(Myint); /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ }}

Given the following lines of code, which of the following is the result of a user entering ABCDEFG when prompted?String stringValue = input.nextLine();char singleChar = stringValue.charAt(0);System.out.println(singleChar);a.)Bb.)Errorc.)Ad.)0

Which of the following lines of code would read in a String, and convert it into a whole number?Scanner input = new Scanner(System.in);Int inputRead = input.next();Scanner input = new Scanner(System.in);String inputRead = input.nextLong();Scanner input = new Scanner(System.in);Int inputRead = input.nextInt();Scanner input = new Scanner(System.in);String inputRead = input.nextLine();

The Scanner's nextLine method may throw which exception? A. InputLineException B. InputMismatchException C. FileNotFoundException D. NoSuchElementException

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.