Guest User

Untitled

a guest
Apr 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Length {
  6. private:
  7. float a;
  8. float b;
  9. float c;
  10. string unit;
  11. void displayUnit()
  12. {
  13. cout << "Enter the number of " << unit << " here." << endl;
  14. }
  15. public:
  16. void inchesToFeet()
  17. {
  18. unit = "inches";
  19. displayUnit();
  20. b = 12;
  21. cin >> a;
  22. c = a / b;
  23. cout << c << " Feet" << endl;
  24. }
  25. void inchesToYards()
  26. {
  27. unit = "inches";
  28. displayUnit();
  29. b = 36;
  30. cin >> a;
  31. c = a / b;
  32. cout << c << " Yards" << endl;
  33. }
  34. void inchesToMiles()
  35. {
  36. unit = "inches";
  37. displayUnit();
  38. b = 5280 * 12;
  39. cin >> a;
  40. c = a / b;
  41. cout << c << " Miles" << endl;
  42. }
  43. void feetToInches()
  44. {
  45. unit = "feet";
  46. displayUnit();
  47. b = 12;
  48. cin >> a;
  49. c = a * b;
  50. cout << c << " Feet" << endl;
  51. }
  52. };
  53.  
  54.  
  55. int main()
  56. {
  57. Length length;
  58. int a;
  59. length.inchesToMiles();
  60. if(a == 1)
  61. {
  62. length.inchesToFeet();
  63. }
  64. else if(a == 2)
  65. {
  66. length.inchesToYards();
  67. }
  68. else if(a == 3)
  69. {
  70. length.feetToInches();
  71. }
  72. return 0;
  73. }
Add Comment
Please, Sign In to add comment