Using C++
Create a header file that defines a class called Building. The variables: the width, the length, and the height. There should be functions to set the width and height, to get the width and height, and to get the volume of the building. Note: each floor of the building is ten feet high. So, also get the number of floors in the building.
Call the header file in a program, also called building. Do not accept invalid input. Display the volume of the building and the number of floors. Submit the header file and the .cpp file.
check out the solution and let me know if any queries through COMMENTS.
---------------------------------------------------------------
note :: save both the files with the same name and in the same folder with the extension .h and .cpp.
---------------------------------------------------------------------------------------
// Building.h
class Building
{
// class variables
private:
float width;
float length;
float height;
// class member functions
public:
void setWidth(float);
void setLength(float);
void setHeight(float);
float getWidth();
float getLength();
float getHeight();
float getVolume();
};
// function definitions
// setters
void Building::setWidth(float w)
{
width=w;
}
void Building::setLength(float l)
{
length=l;
}
void Building::setHeight(float h)
{
height=h;
}
// getters
float Building::getWidth()
{
return width;
}
float Building::getLength()
{
return length;
}
float Building::getHeight()
{
return height;
}
float Building::getVolume()
{
// finding volume and return the result
float volume = width * length * height;
return volume;
}
--------------------------------
// Building.cpp
#include "Building.h" // header in local directory
#include <iostream> // header in standard library
#include<conio.h> // optional header for getch()
function
#include<cmath> // for floor()
using namespace std;
int main()
{
// object of the class Building
Building b1;
// declarations
float width, height, length, volume, floors;
cout << "Input Width: ";
cin>>width;
cout << "Input Length: ";
cin>>length;
cout << "Input Height: ";
cin>>height;
// validation
if(width <=0 || length <=0 || height <=0)
{
// if invalid input
cout << "\n\nInvalid Input!!!";
}
else
{
// call the member functions using class object
b1.setWidth(width);
b1.setLength(length);
b1.setHeight(height);
volume = b1.getVolume();
// print the volume
cout << "\n\nVolume : " << volume;
// get the building height
height = b1.getHeight();
// as each floor is 10ft height
floors = height / 10;
// apply floor function to it to get the whole number as floors
count
floors = floor(floors);
cout << "\nNumber of floors in the Building:
"<<floors;
}
getch();
return 0;
} // main ends
------------------------------------------


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


------------------------------
OUTPUT 1:

OUTPUT 2:

Using C++ Create a header file that defines a class called Building. The variables: the width,...
FOR C++ PLEASE Create a class called "box" that has the following attributes (variables): length, width, height (in inches), weight (in pounds), address (1 line), city, state, zip code. These variables must be private. Create setter and getter functions for each of these variables. Also create two constructors for the box class, one default constructor that takes no parameters and sets everything to default values, and one which takes parameters for all of the above. Create a calcShippingPrice function that...
IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header and implementation file to define an apartment class. Create a driver program to test the class, and create a make file to compile the driver program. Create two files called apartment.h and appartmentImp.cpp along with creating a driver program named testApartment.cpp containing the main function. Program Requirements: • Class attributes should include integers for number of rooms, monthly rent, and square feet, as well...
Create a C++ project Create an Employee class using a separate header file and implementation file. The calculatePay() method should return 0.0f. The toString() method should return the attribute values ("state of the object"). Create an Hourly class using a separate header file and implementation file. The Hourly class needs to inherit from the Employee class The calculatePay() method should return the pay based on the number of hours worked and the pay rate. Remember to calculate overtime! Create a...
C++ project we need to create a class for Book and Warehouse
using Book.h and Warehouse.h header files given. Then make a main
program using Book and Warehouse to read data from book.dat and
have functions to list and find book by isbn
Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...
Create a C++ console program that defines a class named EvenNumber that represents an even number. Create the class inside a separate header file (.h) and then include this header in your main source code file. The class should have one private integer data field to store the even number. The default constructor should initialize the data field to 0. Also define a 1-arg constructor that initializes the object with the specified value. Define a public getter method named getValue...
Visual C#
Homework 2
You are to write a program which will create a class called
Student
Each student has a name age height and weight. These variables
should be declared as private.
Create the correct constructors and functions.
In the main, you will create 5 students.
Input the data for the 5 students from a file which already
has information in it. Name the file “Information.txt”.
After setting up all the data, it is time to sort based on...
Programming: Create a class called City with two public variables: a string to store the name of the city and a float to store the average temperature in Fahrenheit. Create one object of the class that you create and ask the user to enter the city name and the average temperature in Fahrenheit. Store these in the object of the class that you create. Then display the contents of the class. Once that is working, make the variables private and...
In header file (.h) and c++ file format (.cpp). A local company has asked you to write a program which creates an Employee class, a vector of Employee class objects, and fills the objects with employee data, creating a "database" of employee information. The program allows the user to repeatedly search for an employee in the vector by entering the employee's ID number and if found, display the employee's data. The Employee_C class should have the following data and in...
Create a program (in C, not C++) called lab3.c that declares the following variables and displays their values: Declare a character variable with value 'a', and display the character using printf with %c format. Then add a second printf that displays the character with a %d format. Declare a short int variable with a value set to the maximum value of a short int (the maximum value for whatever machine I happen to use to grade your assignment - so...
This is done in C++ Create an Employee class using a separate header file and implementation file. Review your UML class diagram for the attributes and behaviors The calculatePay() method should return 0.0f. The toString() method should return the attribute values ("state of the object"). Create an Hourly class using a separate header file and implementation file. The Hourly class needs to inherit from the Employee class The calculatePay() method should return the pay based on the number of hours...