Write a program that keeps reading strings until it reads the string “xyz”. If your first name is among the entered strings, the program prints “My name is there.” Otherwise, it prints “My name is not listed. Please add it.”
import java.util.*;
public class problem1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
String name,name2="xyz";
Scanner input=new Scanner(System.in);
name=input.next();
while(name!="xyz")
name=input.next();
}
{
if (name.equals("rania"))
System.out.println("my name is there");
else
System.out.println("please enter your name");
}
}