Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program, called SIN_validate, to validate Canadian SIN numbers stored in a file, where the standard Input/Output library should not be used. Only

image text in transcribed

Write a C program, called SIN_validate, to validate Canadian SIN numbers stored in a file, where the standard Input/Output library should not be used. Only Unix input/output system calls can be used for this assignment. The input file consists of SIN numbers, one per line. Your program should open the input file and read the SIN numbers, one at a time as a string. For each SIN number, your program should check whether it is correct, then prints the SIN number, followed by either VALID or NON VALID You have to take care of all possible system call fails by printing the appropriate message, using perror0, and exiting Synopsis validateSIN A Canadian SIN is a 9-digit string that can be validated by checking its digits , following Luhn algorithm, see https://en.wikipedia.org/wiki/social_Insurance_Number Here is an example of how it works 024462284 a SIN, digit-wise Multiplication by this number, the result is given below: 121212121 0 4 4 8 6 4 2 16 4 Then, add all of the digits together note that 16 is 1+6) 4+4+8+6+4+2+1+6 + 4 = 39 If the result is a multiple of 10, then the SIN is valid, otherwise, it is not. Here is a sample run with an example of sins.txt that has 6 SIN numbers %SINvalidate sins . txt 024462284 NON VALID 1234567 23a789099 NON VALID 046454286 VALID - NON VALID // only 7 digits // nondigits are illegal // passed our test Requirement: You must define/implement your own function, int readLine(int fd, char *buff, int size), to read a line from a file. This function uses read0 system call to read a whole line, byte-by-byte (including ). It returns the number of bytes read or, -1 for errors and 0 for end-of-file. Write a C program, called SIN_validate, to validate Canadian SIN numbers stored in a file, where the standard Input/Output library should not be used. Only Unix input/output system calls can be used for this assignment. The input file consists of SIN numbers, one per line. Your program should open the input file and read the SIN numbers, one at a time as a string. For each SIN number, your program should check whether it is correct, then prints the SIN number, followed by either VALID or NON VALID You have to take care of all possible system call fails by printing the appropriate message, using perror0, and exiting Synopsis validateSIN A Canadian SIN is a 9-digit string that can be validated by checking its digits , following Luhn algorithm, see https://en.wikipedia.org/wiki/social_Insurance_Number Here is an example of how it works 024462284 a SIN, digit-wise Multiplication by this number, the result is given below: 121212121 0 4 4 8 6 4 2 16 4 Then, add all of the digits together note that 16 is 1+6) 4+4+8+6+4+2+1+6 + 4 = 39 If the result is a multiple of 10, then the SIN is valid, otherwise, it is not. Here is a sample run with an example of sins.txt that has 6 SIN numbers %SINvalidate sins . txt 024462284 NON VALID 1234567 23a789099 NON VALID 046454286 VALID - NON VALID // only 7 digits // nondigits are illegal // passed our test Requirement: You must define/implement your own function, int readLine(int fd, char *buff, int size), to read a line from a file. This function uses read0 system call to read a whole line, byte-by-byte (including ). It returns the number of bytes read or, -1 for errors and 0 for end-of-file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

=+4. What is the purpose of a sandbox on a wiki? [LO-3]

Answered: 1 week ago