/* * Lab 6, Question 2 * * Name: * Student Number: * * Description: Determines if a SIN is valid. */ public class Lab6Q2 { public static void main(String[] args) { // Use main method to validate either of your methods with test cases // Test the isvalidSSN method System.out.println("SIN: 430 837 013 Valid: "+isvalidSSN(430837013)); // True (valid) System.out.println("SIN: 430 837 014 Valid: "+isvalidSSN(430837014)); // False (invalid) System.out.println("SIN: 633 333 333 Valid: "+isvalidSSN(633333333)); // False (invalid) // Test the generate method (bonus only) System.out.println("The 500000th SIN from 633333333 is: "+generateSIN(633333333,500000)); // 638333336 } // end of main() public static boolean isvalidSSN(int num) { // TODO: Check for number too small or large // Calculate check digit int checkdigit = calcCheckDigit(num/10); // Remove last digit // TODO: Determine if check digit is correct return true; } // end of isvalidSSN() public static int calcCheckDigit(int num) { // Calculates the check digit of a SIN - assumes an 8 digit SSN is provided // TODO: Your code here // HINT: Treat the number as a String and get one digit (character) at a time. // HINT: The other approach is to use modulus (%) to get each digit as a number. // NOTE: Arrays would be useful to store the digits, but we will only see them later. return -1; } // end of calcCheckDigit() /* Given a starting value returns the N-th SIN starting at that number and counting up. If the number given is a valid SIN and numToGenerate is 1, then that SIN is returned. */ public static int generateSIN(int startval, int numToGenerate) { // TODO: Fill your code in here if you want to try the bonus return -1; } } // end of class