You have a unique ID number, which is represented by the variable id, containing a string of numbers. Write a program that continuously takes strings to standard input. If the string is not your ID number, print "This is not your ID number." If it is, print "This is your ID number: " followed by the number, and terminate the loop.my solution is as follows:number = input()while number != id:print("This is not your ID number.")number = input()print("This is your ID number:", number)

Respuesta :

Answer:

//......

public class Brainly {

   public static void main(String[] args) {

       //LETS SAY THE VARIABLE BELOW IS HOLDING YOUR UNIQUE ID

       String uniqueId = "134";

       

       //NOW YOU WANT TO COLLECT INPUTS FROM THE STUDENT OR USER

       //IMPORT THE SCANNER CLASS FIRST

       // THEN YOU CREATE AN OBJECT OF THE SCANNER CLASS

       Scanner input = new Scanner(System.in);

       

       //CREATE A VARIABLE TO HOLD THE USER INPUT

       System.out.println("Enter your Id Number: ");

       String user = input.nextLine();

       

       //NOW YOU CREATE A WHILE LOOP

       //THE WHILE LOOP WILL BE HOLDING A CONDITION

       //AND THE CONDITION IS: If the value in variable 'user' is not equal to the value in 'uniqueId', ask for input from the user again

           while(!user.equals(uniqueId)){

           System.out.println("This is not your Id Number");

           System.out.println("Please enter a valid ID Number");

           user = input.nextLine();

           }

       System.out.println("This is your Id Number: "+uniqueId);

   }

   

}

Explanation: