daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<cmath>
  4. using namespace std;
  5.  
  6.     class Distance {
  7.     private:
  8.     int feet;
  9.     double inches;
  10.  
  11. public:
  12. Distance(): feet(0), inches(0.0) { }
  13. Distance(int ft, double in): feet( ft ), inches( in ) { }
  14. ~Distance() { }
  15. public:
  16.     void getDistance() {
  17.                 cout << "Iveskite pedas ir colius " << endl;
  18.         cin >> feet >> inches;
  19.     }
  20. void showDistance() {
  21. cout << " Pedos: " << feet << "  Coliai: " << inches << endl;
  22. }
  23. void addDistance(Distance d1, Distance d2) {
  24.     inches=d1.inches+d2.inches;
  25.     feet=d1.feet+d2.feet;
  26.     if (inches >=12.0) {
  27.     inches-=12;
  28.     feet++;
  29.     }
  30.  
  31.     }
  32. };
  33. int main ()
  34. {
  35. Distance d1,d2;
  36. Distance d3(1, 2.5);
  37. d2.getDistance();
  38. cout << "d1 = ";
  39. d1.showDistance();
  40. cout << "d1 = ";
  41. d2.showDistance();
  42. cout << "d3 = ";
  43. d3.showDistance();
  44. d1.addDistance(d2,d3);
  45. cout << "d1 = ";
  46. d1.showDistance();
  47. cout << endl;
  48. return 0;
  49. }
RAW Paste Data
Top