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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 12:20, crodriguez87
Usually, when we sniff packets, we are only interested certain types of packets. we can do that by setting filters in sniffing. scapy’s filter use the bpf (berkeley packet filter) syntax; you can find the bpf manual from the internet. set the following filters and demonstrate your sniffer program again (each filter should be set separately): (a) capture only the icmp packet. (b) capture any tcp packet that comes from a particular ip and with a destination port number 23. (c) capture packets comes from or to go to a particular subnet. you can pick any subnet, such as 128.230.0.0/16; you should not pick the subnet that your vm is attached to.
Answers: 3
image
Computers and Technology, 23.06.2019 18:30, sawyerfauver
The computers in the sales department did not have enough data storage capacity to contain all the information the department needed to store, and it was taking a long time for team members to access the data they needed. to fix the problem, the technician installed new, larger hard drives on all the computers.
Answers: 1
image
Computers and Technology, 24.06.2019 17:00, rosepetals2938
Carlos, an algebra teacher, is creating a series of powerpoint presentations to use during class lectures. after writing, formatting, and stylizing the first presentation, he would like to begin writing the next presentation. he plans to insert all-new content, but he wants to have the same formatting and style as in the first one. what would be the most efficient way for carlos to begin creating the new presentation? going under the file tab and opening the first presentation, deleting all content from each page, and adding new content going under the file tab and clicking on new in the left pane, then choosing new from existing going under the design tab and clicking on themes, then selecting the theme that was used for the first template going under the design tab and opening the template that was created for the first presentation
Answers: 2
image
Computers and Technology, 24.06.2019 18:00, bloop3r
Why is a multiview sketch drawinf different from other sketches like isometric, two point, and oblique
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 in other subjects:

Konu
Mathematics, 08.09.2021 04:00
Konu
Mathematics, 08.09.2021 04:00
Konu
Mathematics, 08.09.2021 04:00
Konu
Mathematics, 08.09.2021 04:00