Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Length {
- private:
- float a;
- float b;
- float c;
- string unit;
- void displayUnit()
- {
- cout << "Enter the number of " << unit << " here." << endl;
- }
- public:
- void inchesToFeet()
- {
- unit = "inches";
- displayUnit();
- b = 12;
- cin >> a;
- c = a / b;
- cout << c << " Feet" << endl;
- }
- void inchesToYards()
- {
- unit = "inches";
- displayUnit();
- b = 36;
- cin >> a;
- c = a / b;
- cout << c << " Yards" << endl;
- }
- void inchesToMiles()
- {
- unit = "inches";
- displayUnit();
- b = 5280 * 12;
- cin >> a;
- c = a / b;
- cout << c << " Miles" << endl;
- }
- void feetToInches()
- {
- unit = "feet";
- displayUnit();
- b = 12;
- cin >> a;
- c = a * b;
- cout << c << " Feet" << endl;
- }
- };
- int main()
- {
- Length length;
- int a;
- length.inchesToMiles();
- if(a == 1)
- {
- length.inchesToFeet();
- }
- else if(a == 2)
- {
- length.inchesToYards();
- }
- else if(a == 3)
- {
- length.feetToInches();
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment