Answered step by step
Verified Expert Solution
Question
1 Approved Answer
. Implement a class Address described in Problem P5.3 using the following interface: class Address [ public: Address (unsigned int a_house_number, string a street, string
. Implement a class Address described in Problem P5.3 using the following interface: class Address [ public: Address (unsigned int a_house_number, string a street, string a city, string a_ state, unsigned int a_zipcode Address (unsigned int a_house_number, string a_street, unsigned int a_apt_number, string a_city, string a_state, unsigned int a_zipcode void print); bool comes_before (const Address &a) private: unsigned int house_number unsigned int apt_number; unsigned int zipcode; bool has_apartment; string street string city; string state; string barcode; //constructed based on zipcode // converts barcode to zip code string zipcode_to_barcode (unsigned int zcode); Note: The type used for apartment number and house number must be unsigned int Note: A private data field string barcode of the Address class must be initialized with the bar code obtained by converting the zip code into a string with the help of the encoding table in Exercise 4.16 (re-use the code from Homework 3) . Write a program in which the user is prompted to enter address information which is then used to construct an object of class Address. Then use the member function print to print out the Address information (see the input-output sample). Implement a loop that repeats the request Note: An apartment number is optional. If Address does not have an apartment, the user will indicate this by skipping the input, that is, by pressing Enter'. Hint: To handle such input, one can read a character and check if it is a newline character or not. If it is not, then use cin.unget ) to return the character back to the reading buffer and then read in the integer number using cin. note, if there is an apartment number then the second constructor must be called Submit the following 3 files. The main () function must be in the file hmw-5-4.cpp. The interface of the object Address must be in the file address.h and the description of the member functions of the Address class must be in address.cpp. Before submission make sure you can compile the program in Visual Studio Sample input-output: C:Windows system32 cmd.exe Address input House numbe 1234 Street: Some Dr Apartment number 10 City: Los Angeles State:California Zipcode 90055 Printing the address record Address: 1234 Some D. Apt 10 Los Angeles. California, 90055 Continue (y)? Address input House number 4321 Street:Other Dr Apartment number: City: Los Angeles State: California Zipcode90210 Printing the address record Address: 4321 0ther Dr Los Angeles. California, 90210 Continue (y>? n Press any key to continue
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started