For faster sorting of letters, USPSencourages companies that send large volumes
ID: 3614111 • Letter: F
Question
For faster sorting of letters, USPSencourages companies that send large volumes ofmails
to use a bar code denoting the zip code. Thecoding scheme is given below:
digit code digitcode
1 :::|| 6 :||::
2 ::|:| 7 |:::|
3 ::||: 8 |::|:
4 :|::| 9 |:|::
5 :|:|: 0 ||:::
Here, | denotes a full bar and : denotes a half bar. Note that, for eachcode, there are always two full
bars andthree half bars. For example, :||:: is the code for 6.
For afive-digit zip code, the encoding scheme is as follows. The fiveencoded digits are followed by a
check digit.The check digit is computed as follows: add up all digits andchoose the check digit to
make the suma multiple of 10. For example, the zip code of 17033 has the sum of14, so the check
digit is 6 tomake the sum equal to 20 which is a multiple of 10. Finally add afull bar on each end of
the encodedstring. For example, the bar code for 17033becomes
|:::|||:::|||:::::||:::||::||::|
Write a program that asks the user for a zipcode and prints the bar code. Do not forget the fullbar
on each end of the bar code string.Functions and strings are allowed.
Explanation / Answer
please rate - thanks #include #include using namespace std; void print(int[]); int main() {int zip,digit[6],i,n,check,t; coutzip; check=0; for(i=4;i>=0;i--) {digit[i]=zip%10; check+=digit[i]; zip/=10; } coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.