Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

RoomDimensions Class #ifndef ROOMDIMENSIONS_H #define ROOMDIMENSIONS_H #include

ID: 3771009 • Letter: R

Question

RoomDimensions Class

#ifndef ROOMDIMENSIONS_H

#define ROOMDIMENSIONS_H

#include "FeetInches.h"

#include "RoomCarpet.h"

#include <iostream>

using namespace std;

class RoomDimensions

{

private:

       RoomCarpet Room;

       FeetInches Length;

       FeetInches Width;

       double Arr;

public:

       RoomDimensions( )

       {Arr = 0;}

       RoomDimensions(const FeetInches &obj1, FeetInches &obj2)

       {Length = obj1; Width = obj2;}

       RoomDimensions(RoomCarpet &obj3, double R)

       {Room = obj3; Arr = R; }

       double GetArea()

       {

       Arr=((Length.Multi() * Width.Multi())/12) ;//////////////Take a look at this

       return Arr;}

};  

#endif

RoomDimensions CPP

#include <cstdlib>

#include "RoomDimensions.h"

#include "FeetInches.h"

#include "RoomCarpet.h"

#include <iostream>

using namespace std;

int main()

{

       FeetInches Length(6,6), Width(3,7), Length1, Length2;

       RoomCarpet Room;

       cout << Length.SetFeet() << " ft. " << Length.SetInches() << " inches + " << endl;

       cout << Width.SetFeet() << " ft. " << Width.SetInches() << " inches = " << endl;

       Length1 = Length + Width;

       cout << Length1.SetFeet() << " ft. " << Length1.SetInches() << " inches " << endl;

       cout << " " << endl;

       Length.SetFeet(7);

       Length.SetInches(8);

       Width.SetFeet(5);

       Width.SetInches(6);

       Length1 = Length - Width;

       cout << Length.SetFeet() << " ft. " << Length.SetInches() << " inches - " << endl;

       cout << Width.SetFeet() << " ft. " << Width.SetInches() << " inches = " << endl;

       cout << Length1.SetFeet() << " ft. " << Length1.SetInches() << " inches" << endl;

       cout << " " << endl;

       int LengthFt = 0, WidthFt = 0, LengthIn = 0, WidthIn = 0;

    double Costi = 0;

       Length.SetFeet(8);

       Length.SetInches(7);

       Width.SetFeet(7);

       Width.SetInches(4);

       cout << "Enter feet of length: " << endl;

       cin >> LengthFt;

       cout << "Enter inches of length: " << endl;

       cin >> LengthIn;

       Length.SetFeet(LengthFt);

       Length.SetInches(LengthIn);

       cout << "Length = " << Length.SetFeet()<< " ft. " << "and " << Length.SetInches() << " inches" << endl;

       cout << "Enter feet of Width: " << endl;

       cin >> WidthFt;

       cout << "Enter inches of Width: " << endl;

       cin >> WidthIn;

       Width.SetFeet(WidthFt);

       Width.SetInches(WidthIn);

       cout << "Width = " << Width.SetFeet() << " ft " << "and " << Width.SetInches() << " inches" << endl;

    system ("pause");

       system ("cls");

       RoomDimensions Length3(Length, Width);

       cout << " " << endl;

       Length2.SetFeet(LengthFt);

       Length2.SetInches(LengthIn);

    cout << Length1.SetFeet() << " ft. and " << Length1.SetInches() << " inches being <= " << Length2.SetFeet() << " ft. and "<< Length2.SetInches() << " inches is ";

       if (Length1.SetFeet() <= Length2.SetFeet())

              cout << "true" << endl;

       else

          cout << "false" << endl;

       cout << " " << endl;

cout << Length1.SetFeet() << " ft. and " << Length1.SetInches() << " inches being >= " << Length2.SetFeet() << " ft. and "<< Length2.SetInches() << " inches is ";

       if (Length1.SetFeet() >= Length2.SetFeet())

              cout << "true" << endl;

       else

          cout << "false" << endl;

       cout << " " << endl;

cout << Length1.SetFeet() << " ft. and " << Length1.SetInches() << " inches being not equal " << Length2.SetFeet() << " ft. and "<< Length2.SetInches() << " inches is ";

       if (Length1.SetFeet() != Length2.SetFeet())

              cout << "true" << endl;

       else

          cout << "false" << endl;

       cout << " " << endl;

    cout << Length.SetFeet() << " ft and " << Length.SetInches() << " inches x " << Width.SetFeet() << " ft. " << Width.SetInches() << " inches = " << endl;  

       RoomCarpet Carpet(Length, Width);

       cout << Length3.GetArea() << " square feet " << endl;

       cout << "Enter cost per Square foot" << endl;

       cin >> Costi;

       Room.GetCost(Costi);

       cout << Room.Cost() << endl;

       cout << "Cost at $" << Costi << " per square feet is: " << Length3.GetArea() << endl;   ///Take a look at this This is what I'm trying to do

       system("pause");

       return 0;

      

}

FeetInches Class

#ifndef FEETINCHES_H

#define FEETINCHES_H

class FeetInches

{

private:

       int Feet;

       int Inches;

       void Simplify();

public:

       FeetInches(int F = 0, int I = 0)

       {Feet = F; Inches = I; Simplify();}

       FeetInches(const FeetInches &obj1)

       {Feet = obj1.Feet;

       Inches = obj1.Inches;}

       void SetFeet(int F)

       {Feet = F;}

       int SetFeet() const

       {return Feet;}

       void SetInches(int I)

       {Inches = I; Simplify();}

       int SetInches() const

       {return Inches;}

       FeetInches operator + (const FeetInches &);

       FeetInches operator - (const FeetInches &);

       bool operator <= (const FeetInches &);

       bool operator >= (const FeetInches &);

       bool operator != (const FeetInches &);

int Multi() const;

};

#endif

FeetInches CPP

#include <cstdlib>

#include "FeetInches.h"

#include "RoomDimensions.h"

#include <iostream>

using namespace std;

void FeetInches::Simplify()

{

       if(Inches >= 12)

     {

              Feet += (Inches /12);

              Inches = Inches % 12;

       }

       else if(Inches < 0)

       {

              Feet -= ((abs(Inches)/12)+1);

              Inches = 12 - (abs(Inches)%12);

       }

}

int FeetInches:: Multi() const

{ FeetInches temp;

   temp.Inches = Feet* 12 + Inches;

   return temp.Inches;

}

bool FeetInches:: operator <= (const FeetInches &right)

{

       bool Results;

       if (Feet <= right.Feet)

              Results = true;

       else if (Feet == right.Feet && Inches <= right.Inches)

              Results = true;

       else

              Results = false;

       return Results;

}

bool FeetInches::operator >= (const FeetInches &right)

{

       bool Results;

       if (Feet >= right.Feet)

              Results = true;

       else if (Feet==right.Feet && Inches >= right.Inches)

              Results = true;

       else

              Results = false;

       return Results;

}

bool FeetInches::operator != (const FeetInches &right)

{

       bool Results;

       if (Feet != right.Feet || Inches != right.Inches)

              Results = true;

       else

              Results = false;

       return Results;

}

FeetInches FeetInches::operator +(const FeetInches &right)

{FeetInches temp;

temp.Inches = Inches + right.Inches;

temp.Feet = Feet + right.Feet;

temp.Simplify();

return temp;

}

FeetInches FeetInches::operator -(const FeetInches &right)

{FeetInches temp;

temp.Inches = Inches - right.Inches;

temp.Feet = Feet - right.Feet;

temp.Simplify();

return temp;

}

RoomCarpet Class

#ifndef ROOMCARPET_H

#define ROOMCARPET_H

#include "RoomDimensions.h"

#include "FeetInches.h"

class RoomCarpet

{

private:

       FeetInches Length;

       FeetInches Width;

       double CostPSF;

public:

       RoomCarpet()

       {CostPSF = 0; }

       RoomCarpet(const FeetInches &obj1, FeetInches &obj2)

       {Length = obj1; Width = obj2;}

       RoomCarpet(const RoomCarpet &obj1, double C)

       {CostPSF = C;}

       void GetCost(double C)

       {CostPSF = C; }

       double Cost() const

       {return CostPSF;}

};

#endif

Questions concerning this program: Everything works on this program except one thing. It is when I try to use CostPSF in the Cost Function in RoomCarpet class. I am trying to call this function from the RoomDimensions CPP to give me a cost per square feet This has to be multiplied by the Get Area function in the RoomDimensions Class. I can’t figure out how to use this. It is something that I am doing wrong with the copy constructors.

Explanation / Answer

As per your code i changed RoomDimensions Class

class RoomDimensions{
public:
   RoomDimensions(){};
   RoomDimensions(const RoomDimensions& r) : length(r.length), width(r.width){};
   RoomDimensions(FeetInches l, FeetInches w) : length(l), width(w){};
   FeetInches getArea(){return length.multiply(width);}; // Here get An Area
   FeetInches getLength(){return length;}; //return Length
   FeetInches getWidth(){return width;}; // return width

private:
              RoomCarpet Room;
   FeetInches length;
   FeetInches width;
};


in class FeetInches

int Multi() const; changed as FeetInches multiply(FeetInches f);

use below code

FeetInches FeetInches::multiply(FeetInches f){
   double thisInches = feet*12 + inches;//inches in double data type
   double thatInches = f.getFeet()*12 + f.getInches();
   double in = (thisInches*thatInches)/ 12.0;
   int ft = convertInchesToFeet(in); // convert to feet to inches
   FeetInches product((double)ft,in); // feet inches value
   return product; //return the value of the product
}

remove code

int FeetInches:: Multi() const
{ FeetInches temp;
   temp.Inches = Feet* 12 + Inches;
   return temp.Inches;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote