mercredi 25 décembre 2019

How can i pad 0's to the left?

In this example i want to make it so where the enters any number between this range. If the user enters the number 2 for example, the account number would be like something like this 00000002, where it adds the 0's automatically. Is this possible to do at all in this scenario?

System.out.println("What is your 8 digit Account Number?"); //Enter Account Number.
AccountNumber = ask.nextInt();  //user is asked for an input for the account number. I want input to fall within that range

if (AccountNumber > 00000000 && AccountNumber < 99999999) {   
}       
else  {
 System.out.println("Invalid Account Number \n"); 

 System.out.println("Re-Enter Account Number");
 AccountNumber = ask.nextInt(); 
}

Aucun commentaire:

Enregistrer un commentaire