program UPCCheckDigit; uses crt; var infile,outfile:text; x:integer; UPC:string; oddsum, evensum, checkdigit: integer; begin assign(infile,'DATA31.txt'); reset(infile); assign(outfile,'OUT31.txt'); rewrite(outfile); for x:= 1 to 5 do begin readln(infile,UPC); oddsum := (ord(UPC[1])-48) + (ord(UPC[3])-48) + (ord(UPC[5])-48) + (ord(UPC[7])-48) + (ord(UPC[9])-48) + (ord(UPC[11])-48); evensum := (ord(UPC[2])-48) + (ord(UPC[4])-48) + (ord(UPC[6])-48) + (ord(UPC[8])-48) + (ord(UPC[10])-48); checkdigit := 10 - (oddsum*3 + evensum) mod 10; delete(UPC,12,1); UPC := UPC + char(checkdigit + 48); writeln(outfile,UPC); end; close(infile); close(outfile); end.