I am trying to make a program that inputs the user's name and age and then asks the user on what info he/she wants to know. Here's the program :
import java.util.Scanner; public class name_and_age { static Scanner key = new Scanner(System.in); public static void main(String args[]) { String name = "NAME"; String age = "AGE"; System.out.println("What is your name?"); String a = key.nextLine(); System.out.println("What is your age?"); int b = key.nextInt(); while() { System.out.println("What do you want to know?"); String i = key.nextLine(); if(i.equals(name)) { System.out.println("Your name is "+ a); } if(i.equals(age)) { System.out.println("Your age is" + b); } else { System.out.println("Please either enter age or name"); } } } } I am confused on what to put in the while loop because I want something like
while( (i.equals(name)) || (i.equals(age)) ) except that I want to put not equals in the place of equals. What should I do?
while(( ! i.equals(name)) || (! i.equals(age)))the!is a not operator