1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
/*Josh Krynock CSC 134 80
March 21, 2016
This program prompts the user for their address info
and then creates a check code from the zip code. The zip code is converted to
a barcode and displayed in a printing label.
For extra credit a random zip code generator can be included.
*/
#include <iostream>
#include <iomanip> //THis is to format the outputs.
#include <cstdlib> //This is for generating random zip codes.
using namespace std;
int main()
{
//Variables for string input
string name, street, city, state;
// Variables for the zip code math.
int zip, check,
ones,
tens, tensA,
hund, hundA,
thou, thouA,
tenK, tenKA,
sum;
//This section informs the user of the program's intent.
//It then prompts the user for their information.
cout << "Hello, User. This program will generate ";
cout << "a mailing label for a given user's address. \n";
cout << "Please enter the following information.\n";
cout << "What is your name? ";
getline(cin, name);
cout << "What is your street address? ";
getline(cin, street);
cout << "What is your city? ";
getline(cin, city);
cout << "What is your state? ";
getline(cin, state);
cout << "What is your zip code? ";
cin >> zip;
cout << "\n";
//This part of the program breaks the zipcode into single digits.
//First the ones,
ones = zip % 10;
//then tenths
tens = zip % 100;
tensA = (tens - ones) / 10;
//Hundreths
hund = zip % 1000;
hundA = (hund - tens) / 100;
//Thousandths
thou = zip % 10000;
thouA = (thou - hund) / 1000;
//Ten K
tenK = zip % 100000;
tenKA = (tenK - thou) / 10000;
//This part of the program calculates the check number.
check = (ones - tensA + hundA + thouA + tenKA);
check %= 10;
check = (10-check);
//This part of the program modifies the zip code to display
//it in true bar code form.
if ( ones == 5 )
ones = :|:|:;
//This part of the program displays the postage label.
cout << "\n\n\n\n";
cout << left << "***********************************Postage\n\n";
cout << name << "\n";
cout << street << "\n";
cout << city << " " << state << " " << zip << "\n\n";
cout << "|" << tenKA << " " << thouA << " " << hundA;
cout << " " << tensA << " " << ones << " " << check << "|";
return 0;
}
|