Question: #include #include FeetInches.h using namespace std; int main() { FeetInches first, second; int choice; do { cout < < Menu: 1. Input distances 2. Display

#include #include "FeetInches.h" using namespace std;

int main() { FeetInches first, second; int choice; do { cout << "Menu: 1. Input distances 2. Display distances 3. Compare distances 4. Exit Enter your choice: "; cin >> choice; switch (choice) { case 1: { cout << "Enter a distance in feet and inches. "; cin >> first; cout << "Enter another distance in feet and inches. "; cin >> second; break; } case 2: { cout << "The values you entered are: "; cout << first << " and " << second << endl; break; } case 3: { if (first > second) { cout << first << " is greater than " << second << endl; } else if (first == second) { cout << first << " is equal to " << second << endl; } else { cout << first << " is less than " << second << endl; } break; } case 4: break; default: cout << "Invalid choice. "; break; } } while (choice != 4); return 0; }

------

#ifndef FEETINCHES_H #define FEETINCHES_H

#include using namespace std;

class FeetInches;

ostream& operator << (ostream&, const FeetInches&); istream& operator >> (istream&, FeetInches&);

class FeetInches { private: int feet; int inches; void simplify(); public: FeetInches(); ~FeetInches(); void setFeet(int f);

void setInches(int i);

int getFeet() const; int getInches() const;

FeetInches &operator ++ (); FeetInches operator ++ (int); bool operator > (const FeetInches&); bool operator < (const FeetInches&); bool operator == (const FeetInches&);

friend ostream& operator << (ostream&, const FeetInches&); friend istream& operator >> (istream&, FeetInches&); };

#endif #pragma once ------

#include #include "FeetInches.h" using namespace std;

FeetInches::FeetInches() { setFeet(0); setInches(0); simplify(); }

FeetInches::~FeetInches() {

} void FeetInches::setFeet(int f) { feet = f; }

void FeetInches::setInches(int i) { inches = i; simplify(); }

int FeetInches::getFeet() const { return feet; }

int FeetInches::getInches() const { return inches; }

bool FeetInches::operator > (const FeetInches& right) { return !(*this < right); }

bool FeetInches::operator < (const FeetInches& right) { return !(*this > right); }

bool FeetInches::operator == (const FeetInches& right) { return !(*this > right); }

ostream& operator<<(ostream& strm, const FeetInches& obj) { strm << obj.feet << " feet, " << obj.inches << " inches"; return strm; } istream& operator>>(istream& strm, FeetInches& obj) { strm >> obj.feet >> obj.inches; obj.simplify(); return strm; } FeetInches& FeetInches::operator++() { simplify(); return *this; } FeetInches FeetInches::operator++(int) { FeetInches temp = *this; simplify(); return temp; }

void FeetInches::simplify() {

if (inches == 12) {

feet++; inches == 0; }

else {

}

}

Please add a working simplify which increments the feet every time the 12 inches threshold is met and return the inches value corresponding to the original amount (example 10 feet 13 inches = 11 feet 1inch). Also include a working comparison of the first and second distances. c++

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!