Assignment 5 ============== hhal T.A : Vipul Jain Room 322 McConnell,TA hours Fri 10 - 12 Mail to : HCA5 on MUSICB (all other destinations will be IGNORED) Use P-Mail address TO: HC--@MUSICB.MCGILL.CA to send your 'C' source file and output to your code HC-- on MUSICB. Then E-Mail both to HCA5. To get credit for your assignments they MUST by mailed from your own HC-- code - that's how we keep track of all the students in the class. Due : 5 November 1994 Weight : 25 SOCIAL INSURANCE NUMBER VALIDATION PROGRAM ___________________________________________ Write a 'C' program to validate the accuracy of any Social Insurance Number (SIN). ( or to impress others by guessing the last digit, given the first eight digits ). The Social Insurance Number contains nine digits. ( the first eight digits are assigned, while the ninth is constructed from the first eight, and therefore acts as a check-digit). Ex: SIN = 1 9 3 4 5 6 7 8 7 1st 2nd 3rd 4th 5th 6th 7th 8th check-digit Steps: ( High Level Specifications ). ______________________________ (1) Construct a 4 digit number from the 2nd, 4th, 6th and 8th digit of the SIN. ie. 9 4 6 8 (2) Multiply the constructed digit in step (1) by two. ie. 9 4 6 8 * 2 = 1 8 9 3 6 (3) Cross add all the resulting digits of step (2). ie. 1+8+9+3+6 = 27 (4) Construct a 4 digit number from the 1st, 3rd, 5th and 7th digit of the SIN ie. 1 3 5 7 (5) Cross add all the resulting digits of step (4). ie. 1+3+5+7 = 16 (6) Add the results of step (3) and (5) together. ie. 27 + 16 = 43 (7) If the result of step (6) is a multiple of 10 then the check digit is 0 Otherwise the check is 10 - MOD(results of step (6) , 10 ) ie. 10 - MOD(43,10) = 7 Test you program on the following SIN numbers: 111111111 222222222 333333333 444444444 555555555 666666666 777777777 888888888 999999999 205446651 193456787 your own number (optional) 3 more numbers (be creative)... Requirements: 1) Do NOT use arrays. Call the digits d1 d2 d3 ... d9 2) Use a simple while loop - you will be shown this in class. 3) Nicely formatted output, with message and correct check digit, as below. S.I.N Message Correct Check-Digit _________ _______ ___________________ 111111111 Wrong SIN 8 222222222 Wrong SIN 6 333333333 Wrong SIN 4 444444444 Wrong SIN 2 555555555 Wrong SIN 6 666666666 Wrong SIN 4 777777777 Wrong SIN 2 888888888 Wrong SIN 0 999999999 Wrong SIN 8 205446651 Correct SIN 1 193456787 Correct SIN 7 your own number (optional) 3 more numbers (be creative)... your program should prompt the user for a Social Insurance Number, validate it, and print the Message as above, with the Correct Check-Digit. Your program should loop until the user enters a special character as a social insurance number, or a SIN of 0. NOTE: We assume that if the Check-Digit is correct, then the SIN is a valid number.