continuous working on my project i am stop again for writing the void function in my coding the void displaycode()is Your program must implement the function, displayCode whose prototype is shown below. This function displays the bar code associated with a single digit.
and the void displaybarcode() is Your program must implement the function, displayBarcode whose prototype is shown below. This function displays the bar code associated with the zip code (all zipcode digits) and the correction digit. how do I display my code? is this the right way to write my code?
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int createZipcode();
int extract(int zip, int location);
int correction(int zipcode);
void displaycode(int digit);
void displaybarcode(int digit, int location);
void displaybarcode(int zipcode, int location)
{
printf("l");
for(int i = 0; i <= 5; i++)
{
displaycode(extract(zipcode,1));
displaycode(location);
printf("l\n");
}
}
void displaycode(int zipcode)
{
switch (extract(zipcode,1))
{
case 0:
printf("|||:::");
break;
case 1:
printf("|:::||");
break;
case 2:
printf("|::|:|");
break;
case 3:
printf("|::||:");
break;
case 4:
printf("|:|::|");
break;
case 5:
printf("|:|:|:");
break;
case 6:
printf("|:||::");
break;
case 7:
printf("||:::|");
break;
case 8:
printf("||::|:");
break;
case 9:
printf("||:|::");
break;
}
switch (extract(zipcode,2))
{
case 0:
printf("|||:::");
break;
case 1:
printf("|:::||");
break;
case 2:
printf("|::|:|");
break;
case 3:
printf("|::||:");
break;
case 4:
printf("|:|::|");
break;
case 5:
printf("|:|:|:");
break;
case 6:
printf("|:||::");
break;
case 7:
printf("||:::|");
break;
case 8:
printf("||::|:");
break;
case 9:
printf("||:|::");
break;
}
switch (extract(zipcode,3))
{
case 0:
printf("|||:::");
break;
case 1:
printf("|:::||");
break;
case 2:
printf("|::|:|");
break;
case 3:
printf("|::||:");
break;
case 4:
printf("|:|::|");
break;
case 5:
printf("|:|:|:");
break;
case 6:
printf("|:||::");
break;
case 7:
printf("||:::|");
break;
case 8:
printf("||::|:");
break;
case 9:
printf("||:|::");
break;
}
switch (extract(zipcode,4))
{
case 0:
printf("|||:::");
break;
case 1:
printf("|:::||");
break;
case 2:
printf("|::|:|");
break;
case 3:
printf("|::||:");
break;
case 4:
printf("|:|::|");
break;
case 5:
printf("|:|:|:");
break;
case 6:
printf("|:||::");
break;
case 7:
printf("||:::|");
break;
case 8:
printf("||::|:");
break;
case 9:
printf("||:|::");
break;
}
switch (extract(zipcode,5))
{
case 0:
printf("|||:::");
break;
case 1:
printf("|:::||");
break;
case 2:
printf("|::|:|");
break;
case 3:
printf("|::||:");
break;
case 4:
printf("|:|::|");
break;
case 5:
printf("|:|:|:");
break;
case 6:
printf("|:||::");
break;
case 7:
printf("||:::|");
break;
case 8:
printf("||::|:");
break;
case 9:
printf("||:|::");
break;
}
}
int createZipcode()
{
return 10000 + rand() % 99999;
}
int extract(int zip, int location)
{
while (location <= 4)
{
location++;
zip/=10;
}
return zip % 10;
}
int correction(int zipcode)
{
int sum = 0;
sum = extract(zipcode,1) + extract(zipcode,2)+ extract(zipcode,3) + extract(zipcode,4) +extract(zipcode,5);
return sum;
}
int main()
{
printf("zip code digit barcode\n");
{
int zipcode;
int digit;
int digit2;
int digit3;
int digit4;
int digit5;
int digit6;