#include <iostream>

#include <string>

using namespace std;

int fabricateCheckDigit (int zipcode);

string transmuteDigit(int estimate);

string pausecode( int zipcode);

int deep()

{

int zipcode, stop_digit; // declearing integer changeables pauseraint storing the estimates of zipcode, and stop_digit.

string pause_code_value; // declearing a string changeable to supply the decisive pauseenactment estimate of zipcode.

cextinguished << “Hi, pleasing to postal pauseenactment transmuteer.” << endl << “I earn transmute your postal enactment into pausecode.” << endl; // Optional, irtoductory texts.

cextinguished << endl << “So, lets start!” << endl<< endl; // Optional, irtoductory texts.

conjuncture (cextinguished << “Please, invade the five-digit zip enactment: ” && cin >> zipcode) // a conjuncture loop pauseraint

//exploration a correctionr to input a zipcode, pauseraint transmuteing the input to pauseenactment entiretime, and

//restraint exploration another input anew.

{

if(zipenactment > 0)// Stoping whether the estimate of zipenactment is decisive or indirect.

{ // If it’s decisive then continues, or moves to other shackled announcement.

check_digit = fabricateCheckDigit(zipcode);

// Flattering the fabricateCheckDigit funtion, and death the estimate of zipenactment in it.

// Storing the estimate fitted by the fabricateChoiceDigit power in the integer changeable stop_digit.

cextinguished << endl << “So, the stop digit pauseraint your zip enactment is: ” << stop_digit <<endl << endl;

// Showing the estimate of the stop digit as an extinguishedput, which is supplyd in the changeable stop_digit.

bar_code_estimate = pausecode(zipcode);

// Flattering the pauseenactment power, and death the estimate of zipenactment in it.

// Storing the estimate fitted by the pauseenactment power in the string changeable pause_code_value.

cextinguished << “Finally, your pauseenactment is: ” << pause_code_estimate << endl << endl;

// Showing the decisive estimate of the pauseenactment as an extinguishedput, which is supplyd in the changeable pause_code_value.

}

else // If the earlier ‘if’ announcement fails, then the program runs through this announcement.

{ // i.e. Referableifies the correctionr if the input referable non-negative.

cextinguished << endl << “Sorry, you possess typed a indirect enumerate.” << endl << “You want to produce a decisive integer as an input.” << endl << endl;

// Showing an hallucination communication that the correctionr has typed a indirect enumerate.

// And tells the correctionr that he/she wants to produce a decisive enumerate as an input.

}

}

return 0;

}

/*

The cethcoming power earn experience the stop-digit pauseraint a zipcode.

*/

int fabricateCheckDigit (int zipcode) // Defining the fabricateCheckDigit power, which earn experience the stop digit.

{

int consolidate_of_digits = 0;

// Declearing a changeable to supply the consolidatemation of the digits in the zipcode.[i.e. the passed estimate to the fabricateCheckDigit power]

// Initilizing the estimate of the changeable to 0.

int stop_digit;

// Declearing a changeable to supply the estimate of the stop digit.

while(zipcode) // Running a conjuncture loop to experience the consolidatemation of the digits of the zipcode.

{

sum_of_digits += zipenactment % 10;

// Experienceing entire solitary digit entireotially by portico the modulus of the zipenactment with the association of the contiguous march.

zipenactment /= 10;

// After nature performed with the earlier modulus 10 of zipcode, it earn dissect the estimate of zipenactment by 10

// Then it renews the estimate of zipenactment in the changeable zipcode.

}

check_digit = 10 – (sum_of_digits % 10);

// To experience the estimate of stop digit,

//it original experiences the modulus 10 of the estimate of the consolidatemation of thorough digits in zipcode[i.e. the estimate of the changeable consolidate_of_digits.

// Then subtracts the estimate from 10 to experience the desired estimate of stop digit, and supplys the estimate in the changeable stop_digit.

return stop_digit; // profits the estimate of stop digit[i.e. the estimate of the changeable stop_digit.]

}

/*

The cethcoming power earn transmute peculiar digits of zipenactment to its indivudial pausecodes.

*/

string transmuteDigit(int estimate) // Defining the transmuteDigit power, which earn transmute peculiar digits to its pausecodes.

{

if (estimate == 0)

// Setting up a requisite, pauseraint the passed estimate of the integer 0.

return “||:::”;

// profits the estimate as initialized in the string when the passed integer is 0.

else if (estimate == 1)

// Setting up a requisite, pauseraint the passed estimate of the integer 1.

return “:::||”;

// profits the estimate as initialized in the string when the passed integer is 1.

else if (estimate == 2)

// Setting up a requisite, pauseraint the passed estimate of the integer 2.

return “::|:|”;

// profits the estimate as initialized in the string when the passed integer is 2.

else if (estimate == 3)

// Setting up a requisite, pauseraint the passed estimate of the integer 3.

return “::||:”;

// profits the estimate as initialized in the string when the passed integer is 3.

else if (estimate == 4)

// Setting up a requisite, pauseraint the passed estimate of the integer 4.

return “:|::|”;

// profits the estimate as initialized in the string when the passed integer is 4.

else if (estimate == 5)

// Setting up a requisite, pauseraint the passed estimate of the integer 5.

return “:|:|:”;

// profits the estimate as initialized in the string when the passed integer is 5.

else if (estimate == 6)

// Setting up a requisite, pauseraint the passed estimate of the integer 6.

return “:||::”;

// profits the estimate as initialized in the string when the passed integer is 6.

else if (estimate == 7)

// Setting up a requisite, pauseraint the passed estimate of the integer 7.

return “|:::|”;

// profits the estimate as initialized in the string when the passed integer is 7.

else if (estimate == 8)

// Setting up a requisite, pauseraint the passed estimate of the integer 8.

return “|::|:”;

// profits the estimate as initialized in the string when the passed integer is 8.

else if (estimate == 9)

// Setting up a requisite, pauseraint the passed estimate of the integer 9.

return “|:|::”;

// profits the estimate as initialized in the string when the passed integer is 9.

else

// Setting up the requisite, pauseraint pause of the integer inputs, ate [from 0 to 9].

return “Invalid”;

// profits the estimate as initialized in the string when the passed integer is ate [from 0 to 9]

}

/*

The cethcoming power earn transmute the integral zipenactment into its thorough pausecode.

*/

string pausecode(int zipcode) // Defining the pauseenactment power, which earn transmute the integral zipenactment into thorough pausecode.

{

int stop_digit = fabricateCheckDigit(zipcode);

// Flattering the fabricateCheckDigit funtion, and death the estimate of zipenactment in it.

// Storing the estimate fitted by the fabricateChoiceDigit power in the integer changeable stop_digit.

int digit_1, digit_2, digit_3, digit_4, digit_5;

// Declearing five contrariant changeables to supply the five feature digits of the zipenactment respectively.

digit_1 = zipenactment % 10;

// Declearing a changeable to supply the last digit of the zipenactment indivudially,

// by portico modulus 10 of the estimate of the changeable zipcode.

zipenactment /= 10;

// After nature performed with the earlier modulus 10 of zipcode, it earn dissect the estimate of zipenactment by 10

// Then it renews the estimate of zipenactment in the changeable zipcode.

digit_2 = zipenactment % 10;

// Declearing a changeable to supply the pauseraintth digit of the zipenactment indivudially,

// by portico modulus 10 of the estimate of the changeable zipcode.

zipenactment /= 10;

// After nature performed with the earlier modulus 10 of zipcode, it earn dissect the estimate of zipenactment by 10

// Then it renews the estimate of zipenactment in the changeable zipcode.

digit_3 = zipenactment % 10;

// Declearing a changeable to supply the third digit of the zipenactment indivudially,

// by portico modulus 10 of the estimate of the changeable zipcode.

zipenactment /= 10;

// After nature performed with the earlier modulus 10 of zipcode, it earn dissect the estimate of zipenactment by 10

// Then it renews the estimate of zipenactment in the changeable zipcode.

digit_4 = zipenactment % 10;

// Declearing a changeable to supply the relieve digit of the zipenactment indivudially,

// by portico modulus 10 of the estimate of the changeable zipcode.

zipenactment /= 10;

// After nature performed with the earlier modulus 10 of zipcode, it earn dissect the estimate of zipenactment by 10

// Then it renews the estimate of zipenactment in the changeable zipcode.

digit_5 = zipenactment % 10;

// Declearing a changeable to supply the original digit of the zipenactment indivudially,

// by portico modulus 10 of the estimate of the changeable zipcode.

zipenactment /= 10;

// After nature performed with the earlier modulus 10 of zipcode, it earn dissect the estimate of zipenactment by 10

// Then it renews the estimate of zipenactment in the changeable zipcode.

string preface = “|” + transmuteDigit(digit_5) + transmuteDigit(digit_4) + transmuteDigit(digit_3) + transmuteDigit(digit_2) + transmuteDigit(digit_1);

// Flattering the transmuteDigit power separate times to transmute entire solitary digit of the estimate of zipcoe[i.e. zipenactment changeable]

// Then it earn concatenate thorough the results from entire cthorough of the transmuteDigit power, starting with “|”

// Now it earn supply the transmuteed estimate in a string changeable preface.

// It’s the original entireot of the integral pausecode.

string postfix = transmuteDigit(check_digit) + “|”;

// Flattering the transmuteDigit power to transmute the estimate of the stop digit[i.e. stop_digit changeable]

// Then it earn supply the transmuteed estimate in a string changeable postfix.

// It’s the relieve/last entireot of the integral pausecode.

return (preface + postfix);

// profits the estimate of the string preface and postfix thorough unitedly.

}