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 00:40
Reading characters and strings from the keyboard: consider the following c++ program 1. #include 2. #include 3. using namespace std; 4. mystring1 5. 6. int main() 7. { 8. 9. string mystring1, mystring2; mychar1 10. 11. 12. char mychar1, mychar2; 13. 14. cout< < "enter a string: "; mychar2 15. 16. cin> > mystring1; // 17. cin.get(mychar1); 18. cin> > mychar2; 19. getline(cin,mystring2); mystring2 20. 21. 22. cout<
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
Which cultural aspect does this type of song best portray? a german polka dance
Answers: 1
question
Computers and Technology, 22.06.2019 23:00
In which part of a professional email should you try to be brief, but highly descriptive?
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
What is the penalty for violating section 1201 of title 17 chapter 21 of the us code
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
Biology, 29.03.2020 09:14
Questions on the website: 13722367