subject

Creating a class in c++in this lab, you create a programmer-defined class and then use it in a c++ program. the program should create two rectangle objects and find their area and perimeter. instructionsensure the class file named rectangle. cpp is open in your editor. in the rectangle class, create two private attributes named length and width. bothlength and width should be data type double. write public set methods to set the values for length and width. write public get methods to retrieve the values for length and width. write a public calculatearea()method and a public calculateperimeter() method to calculate and return the area of the rectangle and the perimeter of the rectangle. open the file named myrectangleclassprogram. cpp. in the myrectangleclassprogram, create two rectangle objects named rectangle1 and rectangle2 using the default constructor as you saw in myemployeeclassprogram. cpp. set the length of rectangle1 to 10.0 and the width to 5.0. set the length of rectangle2 to 7.0 and the width to 3.0.print the value of rectangle1’s perimeter and area, and then print the value of rectangle2’s perimeter and area. execute the program by clicking the "run code" button at the bottom of the screen given code // rectangle. cppusing namespace std; class rectangle{ public: // declare public methods here private: // create length and width here}; void rectangle: : setlength(double len){ }void rectangle: : setwidth(double wid){ // write setwidth here}double rectangle: : getlength(){ // write getlength here}double rectangle: : getwidth(){ // write getwidth here} double rectangle: : calculatearea(){ // write calculatearea here}double rectangle: : calculateperimeter(){ // write calculateperimeter here} other given code // this program uses the programmer-defined rectangle class.#include "rectangle. cpp"#include using namespace std; int main(){ rectangle rectangle1; rectangle rectangle2; rectangle1.setlength(10.0); rectangle1.setwidth(5.0); rectangle2.setlength(7.0); rectangle2.setwidth(3.0); cout < < "perimeter of rectangle1 is " < < rectangle1.calculateperimeter() < < endl; cout < < "area of rectangle1 is " < < rectangle1.calculatearea() < < endl; cout < < "perimeter of rectangle2 is " < < rectangle2.calculateperimeter() < < endl; cout < < "area of rectangle2 is " < < rectangle2.calculatearea() < < endl; return 0; }

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:40
You begin your first day of responsibilities by examining the recent is security breach at gearup to get ideas for safeguards you will take. at gearup, criminals accessed the company's improperly-secured wireless system and stole customers' credit card information as well as employee social security numbers. what kind of computer crime did gearup face?
Answers: 3
question
Computers and Technology, 23.06.2019 22:30
The output voltage of a power supply is assumed to be normally distributed. sixteen observations are taken at random on voltage are as follows: 10.35, 9.30, 10.00, 9.96, 11.65, 12.00, 11.25, 9.58, 11.54, 9.95, 10.28, 8.37, 10.44, 9.25, 9.38, and 10.85
Answers: 1
question
Computers and Technology, 24.06.2019 08:30
Intellectual property rights are exclusive rights that protect both the created and the creation. ipr offers exclusively what benefits to the person or people covered by it
Answers: 3
question
Computers and Technology, 24.06.2019 15:00
Universal windows platform is designed for which windows 10 version?
Answers: 1
You know the right answer?
Creating a class in c++in this lab, you create a programmer-defined class and then use it in a c++ p...
Questions
Questions on the website: 13722360