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

I need a c++ visual basic program that will. Carpet Calculator. This problem sta

ID: 667125 • Letter: I

Question

I need a c++ visual basic program that will.

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

// FeetInches.h
#ifndef FEETINCHES_H
#define FEETINCHES_H
class FeetInches //feetinches class
{
private:
int feet;
int inches;
void simplify();
public:
FeetInches(int ft = 0, int i = 0) //constructoe
{
feet = ft;
inches = i;
simplify();
}
//getter setter methods
void setFeet(int ft)
{
feet = ft;
}
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: //variables declared
int w;
int l;
public://constructor
RoomDimension(int len, int wid)
{
l=len;
w=wid;
}
FeetInches width;
FeetInches length;
int getArea() const //calcualting area
{
return l*w;
}
};
  
---------------------------------------------------------------------------------

// RoomCarpet.h
class RoomCarpet //this is the class where actual calculations are done
{
private:
RoomDimension roomDimensions;
double carpetCost;
public:
RoomCarpet(RoomDimension dim, double cost) //constructor
{
roomDimensions = dim;
carpetCost = cost;
}
double getTotalCost() const //method to calcualte cost
{
return carpetCost * roomDimensions.getArea();
}
};

--------------------------------------------------------------------

// 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 length;
int width;
double cost;
//Reading data from user
cout << "Enter Length";
cin >> length;
cout<<" Enter width";
cin>>width;
cout<<"Enter cost";
cin>>cost;
//creating roomDimension and roomCarpet objects
RoomDimension dimension = new RoomDimension(length,width);
RoomCarpet carpet = new carpet(dimension,cost);
//calculating cost by calling getTotalCost method
cout<<"Finally Carpet cost Calculated is: "<<carpet.getTotalCost();
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