Note that there are some explanatory texts on larger screens.

plurals
  1. POTPIN number validation in java, c++ or c#
    primarykey
    data
    text
    <p>I have small requirement for TPIN validation in my college project, The requirement is, we should not allow the user to set his TPIN in the below scenarios .</p> <ol> <li>TPIN should not be in sequence. (either ascending or descending ex: 123456, 456789, 987654 or 654321)</li> <li>TPIN should not start from Zero (ex: 0127865, 098764)</li> <li>TPIN should not be repetitive digit (ex: 888888,222222 etc.)</li> </ol> <p>For the third one my idea is to divide the number by 11 and check for the reminder.. </p> <p>Any ideas plz..</p> <pre><code>public class Validate { public static void main(String[] args) { int iTpin = Integer.parseInt(args[0]); // Converted string to int System.out.println("The entered TPIN is:"+iTpin); boolean flag = validate(iTpin); if (flag== true) System.out.println("The entered TPIN is valid"); else System.out.println("The entered TPIN is Invalid"); } public static boolean validate(int passedTpin) { if (passedTpin == 0) return false; else if ( passedTpin%11 == 0) return false; else return true; } } </code></pre> <p>Finally created code for the sequence of digits. It might be useful for others</p> <pre><code>private static boolean containsRepetitiveDigits(String tpin) { char firstChar = tpin.charAt(0); for (int i = 1; i &lt; tpin.length(); i++) { char nextChar = tpin.charAt(i); if ((Character.valueOf(nextChar)).compareTo(Character .valueOf(firstChar)) != 0) { return false; } } System.out.println("Error:TPIN contains repetitive digits"); return true; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload