Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- class Address
- {
- public:
- Address();
- Address(string streetName, string cityName, string stateName
- ,int houseNumber, int postalCode, int apartmentNumber);
- void set_postalCode(int new_salary);
- void set_apartmentNubmer(int new_apartmentNumber);
- string get_street() const;
- string get_state() const;
- string get_city() const;
- void get_postal() const;
- void get_apartment() const;
- void get_house() const;
- private:
- string streetName;
- string cityName;
- string stateName;
- int postalCode;
- int apartmentNumber;
- int houseNumber;
- };
- Address::Address(string state, string city, string street,int apartment,
- int house, int postal)
- {
- streetName = street;
- stateName = state;
- cityName = city;
- postalCode = postal;
- apartmentNumber = apartment;
- houseNumber = house;
- }
- Address::Address()
- {
- }
- string Address::get_city() const
- {
- cout << cityName;
- return cityName;
- }
- string Address::get_street() const
- {
- cout << streetName;
- return streetName;
- }
- string Address::get_state() const
- {
- cout << stateName;
- return stateName;
- }
- void Address::get_apartment() const
- {
- cout << apartmentNumber;
- }
- void Address::get_house() const
- {
- cout << houseNumber;
- }
- void Address::get_postal() const
- {
- cout << postalCode;
- }
- int main()
- {
- string best_address;
- int best_postalcode;
- bool more = true;
- while(more)
- {
- int next_postalcode;
- string next_address;
- cout<< "what is your address?";
- getline(cin, next_address);
- cout << "Please enter your postal code";
- cin >> next_postalcode;
- string remainder;
- getline(cin, remainder);
- if(next_postalcode > best_postalcode )
- {
- best_address = next_address;
- best_postalcode = next_postalcode;
- }
- cout << "More data? (y/n)";
- string answer;
- getline(cin, answer);
- if (answer != "y")more = false;
- }
- cout << "The address that is further is " << best_address <<" "<< best_postalcode<< "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement