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

I want C++ Programming Carpet Calculator. This problem starts with the FeetInche

ID: 3811139 • Letter: I

Question

I want C++ Programming

Carpet Calculator. This problem starts with the FeetInches class that is provided in the course Content area on the assignment page for this week. This program will show how classes will interact with each other as data members within another class. Modify the FeetInches class by overloading the following operators which should all return a bool. <= >= !=

Next add a copy constructor to the FeetInches class and a multiply function.

The copy constructor should accept a FeetInches object as an argument. It will assign the feet attribute the value in the argument’s feet attribute and do the same for the inches attributes.

The multiply function should accept a FeetInches object as an argument. The argument object’s feet and inches attributes will be multiplied by the calling object’s feet and inches attributes. It will return a FeetInches object containing the result of the multiplication.

Next create a class called RoomDimension which will have its class declaration in RoomDimension.h and its implementation in RoomDimension.cpp. This class will have two data members which have a data type of FeetInches, one for the length of the room and another for the width of the room. The multiply function in FeedInches will be used to calculate the area of the room. RoomDimension will have a function that returns the area of the room as a FeetInches object.

Next create a class called RoomCarpet class that has a RoomDimension object as an attribute. This class will have its class declaration in RoomCarpet.h and its implementation in RoomCarpet.cpp. It should also have an attribute for the cost of the carpet per square foot. It will have a member function that returns the total cost of the carpet. For example, a room that is 12 feet long and 10 feet wide has an area of 120 square feet. If the cost per square foot is $8 then the cost to carpet the room will be $960 (120 x 8).

The main for this program will create an instance of RoomCarpet and ask the user for the dimensions of the room and the price per square foot for the carpet. The application should then display the total cost of the carpet. It should allow the user to continue doing more calculations until the user indicates they are done.

Explanation / Answer

#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();
       }
       void setFeet(int f)
       {
           feet = f;
       }
       void setInches(int i)
       {
           inches = i;
           simplify();
       }
       int getFeet() const
       {
           return feet;
       }
       int getInches() const
       {
           return inches;
       }
       FeetInches operator + (const FeetInches &);
       FeetInches operator - (const FeetInches &);
};
#endif
// RoomDimension.h
#include "FeetInches.h"
class RoomDimension
{
   private:
       int w;
       int l;
   public:
       FeetInches width;
       FeetInches length;
};
  
// RoomCarpet.h
class RoomCarpet
{
   private:
   public:
};
// FeetInches.cpp
#include <cstdlib>
#include "FeetInches.h"
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);
   }
}
FeetInches FeetInches::operator - (const FeetInches &right)
{
   FeetInches temp;
   temp.inches = inches - right.inches;
   temp.feet = feet - right.feet;
   temp.simplify();
   return temp;
}
// RoomMain.cpp
#include "RoomCarpet.h"
#include "RoomDimension.h"
#include "FeetInches.h"
#include <iostream>
using namespace std;
int main()
{
   int l;
   int w;
   cout << "What are the dimensions of the room? ";
   cin >>
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote