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, 23.06.2019 04:00
In a word processing program, such as microsoft word, which feature to you choose the desired picture enhancement?
Answers: 2
question
Computers and Technology, 23.06.2019 12:00
Using the list, you can select the number of photos that will appear on each slide. a. theme b. frame shape c. pictures in album d. picture layout
Answers: 1
question
Computers and Technology, 23.06.2019 17:30
What are the most commonly found items in the trash according to the municipal solid waste report?
Answers: 1
question
Computers and Technology, 24.06.2019 03:00
With editing, word automatically displays a paste options button near the pasted or moved text. a. cut-and-paste b. drag-and-drop c. inline d. copy-and-carry
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
question
Mathematics, 27.02.2020 04:30