Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3.  
  4. using namespace std;
  5.  
  6. class Address
  7. {
  8. public:
  9. Address();
  10. Address(string streetName, string cityName, string stateName
  11. ,int houseNumber, int postalCode, int apartmentNumber);
  12. void set_postalCode(int new_salary);
  13. void set_apartmentNubmer(int new_apartmentNumber);
  14. string get_street() const;
  15. string get_state() const;
  16. string get_city() const;
  17. void get_postal() const;
  18. void get_apartment() const;
  19. void get_house() const;
  20. private:
  21. string streetName;
  22. string cityName;
  23. string stateName;
  24. int postalCode;
  25. int apartmentNumber;
  26. int houseNumber;
  27. };
  28. Address::Address(string state, string city, string street,int apartment,
  29. int house, int postal)
  30. {
  31. streetName = street;
  32. stateName = state;
  33. cityName = city;
  34. postalCode = postal;
  35. apartmentNumber = apartment;
  36. houseNumber = house;
  37. }
  38. Address::Address()
  39. {
  40.  
  41. }
  42. string Address::get_city() const
  43. {
  44. cout << cityName;
  45. return cityName;
  46. }
  47. string Address::get_street() const
  48. {
  49. cout << streetName;
  50.  
  51. return streetName;
  52. }
  53. string Address::get_state() const
  54. {
  55. cout << stateName;
  56. return stateName;
  57. }
  58. void Address::get_apartment() const
  59. {
  60. cout << apartmentNumber;
  61. }
  62. void Address::get_house() const
  63. {
  64. cout << houseNumber;
  65.  
  66. }
  67. void Address::get_postal() const
  68. {
  69. cout << postalCode;
  70. }
  71. int main()
  72. {
  73. string best_address;
  74. int best_postalcode;
  75.  
  76. bool more = true;
  77. while(more)
  78. {
  79. int next_postalcode;
  80. string next_address;
  81.  
  82.  
  83. cout<< "what is your address?";
  84. getline(cin, next_address);
  85.  
  86. cout << "Please enter your postal code";
  87. cin >> next_postalcode;
  88.  
  89. string remainder;
  90. getline(cin, remainder);
  91.  
  92.  
  93. if(next_postalcode > best_postalcode )
  94. {
  95. best_address = next_address;
  96. best_postalcode = next_postalcode;
  97. }
  98.  
  99. cout << "More data? (y/n)";
  100. string answer;
  101. getline(cin, answer);
  102. if (answer != "y")more = false;
  103. }
  104. cout << "The address that is further is " << best_address <<" "<< best_postalcode<< "\n";
  105. return 0;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement