Strings have two basic methods that you will need for this assignment:
s.equals(t)
- which is true if s
and t
contain the same string and
false if they do not.keyb.nextLine()
- which reads in an entire
line of text as a string.An example of how this may be used:
Scanner keyb = new Scanner(System.in); String s = new String(); boolean p, q; s = keyb.nextLine(); p = s.equals("The end"); q = s.equals("the end");
If the user typed in "The end" p is true and q is false (equals is case sensitive).
Write a program that prompts the user for a line of text, prints it and repeats this until the user types "The end"