Question: Error Correcting Postal Codes Given the following input, write the code so that it will read in the postal codes, then determine the sum of
Error Correcting Postal Codes Given the following input, write the code so that it will read in the postal codes, then determine the sum of the digits in each part of the code. If the sum in each part == 2 then write valid' else write 'invalid. Treat each line separately. The codes for the different digits are: digit code 1 00011 00101 00110 01001 5 01010 01100 10001 8 10010 10100 11000 O 00 OWN 9 example data: : 1 11000 00011 01010 01100 01100 00011 10100 10010 00011 10100 00110 00011 1 1 11000 00011 01010 01001 11000 10100 01010 01100 01010 01010 00011 10100 1 1 01100 01010 01010 00101 10001 10000 00110 01100 00011 00110 00011 00110 1 1 01001 10001 10100 10010 11000 11001 00011 11000 01010 00011 01010 00110 1 1 00101 00110 10100 01100 11000 00011 10001 11000 00110 00011 10100 10100 1 1 10001 01001 01001 01010 10001 01001 01001 10001 00101 01100 01100 01001 1 Note row 3 column 6 is 10000 it should be 10010, which is 8. Sample logic for the program loop to read 6 lines using 'getline()', read in 1 line print the line just read in set status - valid loop to pick off 12 groups loop to look at 5 characters count the l's end loop if the count is not equal to 2 then set 'status' equal to "invalid" end loop print status end loop Sample output using the above example data: 1 11000 00011 01010 01100 01100 00011 10100 10010 00011 10100 00110 00011 1 valid 1 11000 00011 01010 01001 11000 10100 01010 01100 01010 01010 00011 10100 1 valid 1 01100 01010 01010 00101 10001 10000 00110 01100 00011 00110 00011 00110 1 invalid 1 01001 10001 10100 10010 11000 11001 00011 11000 01010 00011 01010 00110 1 invalid 1 00101 00110 10100 01100 11000 00011 10001 11000 00110 00011 10100 10100 1 valid 1 10001 01001 01001 01010 10001 01001 01001 10001 00101 01100 01100 01001 1 valid
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
