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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
//This program prints a mailing label with all necessary information
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
using namespace std;
int
main()
{
string name, address, state, city, checkdigit1, first1,
second1, third1, fourth1, fifth1;
int zipcode, mailing, choice;
int first, second, third, fourth, fifth, sum = 0, checkdigit;
const double POSTAGEL = 0.49, POSTAGEE = 0.98, POSTAGEP = 2.54;
double postage, totalpostage;
float total = 0.0, weight;
bool done = false;
const int letter = 1, envelope = 2, parcel = 3;
const int single_mailing = 1, multiple_mailing = 2, quit = 3;
cout << fixed << showpoint << setprecision(2);
cout << " Welcome to the Mailing Label Printing System" << endl;
cout << " " << endl;
cout << "1 - Single mailing" << endl;
cout << "2 - Multiple mailing" << endl;
cout << "3 -- Quit" << endl;
cout << "Enter your choice: ";
do {
// prompt for a choice until they give one that's valid
while (true) {
cin >> choice;
if (1 <= choice && choice <= 3) {
break;
}
cout << "****************************************" << endl;
cout << "The valid choices are 1 through 3." << endl;
cout << "1 - Single mailing" << endl;
cout << "2 - Multiple mailing" << endl;
cout << "3 -- Quit" << endl;
cout << "Enter your choice again: ";
}
switch (choice) {
case 1:
//single mailing label
cin.clear();
cin.sync();
/* cout << "Please enter your name: ";
getline(cin, name);
cout << "Please enter your address: ";
getline(cin, address);
cout << "Enter the city you live in: ";
getline(cin, city);
cout << "Enter the state you live in: ";
cin >> state ; */
cout << "Enter the zipcode you live in: ";
cin >> zipcode;
cout << "Enter 1 for Letter 2 for Envelope 3 for Parcel: ";
cin >> mailing;
cout << "Weight of the item to be mailed: ";
cin >> weight;
//calculate the check digit
//Break the five digit zip code into individual digits
first = zipcode / 10000,
second = zipcode / 1000 % 10, third = zipcode / 100 % 10;
fourth = zipcode / 10 % 10;
fifth = zipcode % 10;
//add up the five digit zip code
sum = first + second + third + fourth + fifth;
// calculate the checkdigit
checkdigit = sum % 10;
checkdigit = (10 - checkdigit);
// conditions
if (first == 0)
first1 = "||:::";
else if (first == 1)
first1 = ":::||";
else if (first == 2)
first1 = "::|:|";
else if (first == 3)
first1 = "::||:";
else if (first == 4)
first1 = ":|::|";
else if (first == 5)
first1 = ":|:|:";
else if (first == 6)
first1 = ":||::";
else if (first == 7)
first1 = "|:::|";
else if (first == 8)
first1 = "|::|:";
else if (first == 9)
first1 = "|:|::";
if (second == 0)
second1 = "||:::";
else if (second == 1)
second1 = ":::||";
else if (second == 2)
second1 = "::|:|";
else if (second == 3)
second1 = "::||:";
else if (second == 4)
second1 = ":|::|";
else if (second == 5)
second1 = ":|:|:";
else if (second == 6)
second1 = ":||::";
else if (second == 7)
second1 = "|:::|";
else if (second == 8)
second1 = "|::|:";
else if (second == 9)
second1 = "|:|::";
if (third == 0)
third1 = "||:::";
else if (third == 1)
third1 = ":::||";
else if (third == 2)
third1 = "::|:|";
else if (third == 3)
third1 = "::||:";
else if (third == 4)
third1 = ":|::|";
else if (third == 5)
third1 = ":|:|:";
else if (third == 6)
third1 = ":||::";
else if (third == 7)
third1 = "|:::|";
else if (third == 8)
third1 = "|::|:";
else if (third == 9)
third1 = "|:|::";
if (fourth == 0)
fourth1 = "||:::";
else if (fourth == 1)
fourth1 = ":::||";
else if (fourth == 2)
fourth1 = "::|:|";
else if (fourth == 3)
fourth1 = "::||:";
else if (fourth == 4)
fourth1 = ":|::|";
else if (fourth == 5)
fourth1 = ":|:|:";
else if (fourth == 6)
fourth1 = ":||::";
else if (fourth == 7)
fourth1 = "|:::|";
else if (fourth == 8)
fourth1 = "|::|:";
else if (fourth == 9)
fourth1 = "|:|::";
if (fifth == 0)
fifth1 = "||:::";
else if (fifth == 1)
fifth1 = ":::||";
else if (fifth == 2)
fifth1 = "::|:|";
else if (fifth == 3)
fifth1 = "::||:";
else if (fifth == 4)
fifth1 = ":|::|";
else if (fifth == 5)
fifth1 = ":|:|:";
else if (fifth == 6)
fifth1 = ":||::";
else if (fifth == 7)
fifth1 = "|:::|";
else if (fifth == 8)
fifth1 = "|::|:";
else if (fifth == 9)
fifth1 = "|:|::";
if (checkdigit == 0)
checkdigit1 = "||:::";
else if (checkdigit == 1)
checkdigit1 = ":::||";
else if (checkdigit == 2)
checkdigit1 = "::|:|";
else if (checkdigit == 3)
checkdigit1 = "::||:";
else if (checkdigit == 4)
checkdigit1 = ":|::|";
else if (checkdigit == 5)
checkdigit1 = ":|:|:";
else if (checkdigit == 6)
checkdigit1 = ":||::";
else if (checkdigit == 7)
checkdigit1 = "|:::|";
else if (checkdigit == 8)
checkdigit1 = "|::|:";
else if (checkdigit == 9)
checkdigit1 = "|:|::";
// Display the collected data.
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << "*******************************$" << "" << postage << endl;
cout << "" << endl;
cout << "" << endl;
cout << name << endl;
cout << address << endl;
cout << city << " " << state << " " << zipcode << " " << endl;
cout << "|" << "" << first1 << "" << second1 << "" << third1 << "" <<
fourth1 << "" << fifth1 << "" << checkdigit1 << "" << "|" << endl;
break;
case 2:
cout << "Case 2 is not yet implemented\n";
break;
case 3:
done = true;
break;
}
} while (!done);
}
|