I want this program in the same file .cpp only. please test the program before you give it to me. please do the program before the deadline.

1 answer below »
I want this program in the same file .cpp only. please test the program before you give it to me. please do the program before the deadline.
Answered Same DaySep 29, 2021

Answer To: I want this program in the same file .cpp only. please test the program before you give it to me....

Sudipta answered on Oct 01 2021
141 Votes
#include
#include
#include
//for exit()
using namespace std;
class ZipCode{
publ
ic:
ZipCode(int zip); //takes zip code as an integer input
ZipCode(string bar); //takes zip code as a string (0, 1) input
int getZipCode(); //returns the zip code as an integer
string getBarCode();//returns the zip code as a string

private:
int zipCode;
string barCode;
bool checkBarCode(); //checks the first and last digit is 1 or not and also if the length is 27 or not
bool checkTwoOnes();//checks if exactly two 1's in each group of 5 digits or not
int calculateZipCode(); //returns the final result
string getFiveDigitValues();
};
ZipCode::ZipCode(int zip) : zipCode(zip){}
ZipCode::ZipCode(string bar) : barCode(bar){}
int ZipCode::getZipCode(){
if(checkBarCode()){
if(checkTwoOnes()){
zipCode = calculateZipCode();
}
else{
cout << "There are not exact two one's in each group of 5'!";
exit(1);
}
}
else{
cout << "Invalid Bar-code!";
exit(1);
}
return zipCode;
}
string ZipCode::getBarCode(){
barCode =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here