Write public set methods to set values for length and width

Assignment Help Computer Engineering
Reference no: EM131984713

Assignment

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.

Instructions

Ensure the class file named Rectangle.cpp is open in your editor.

In the Rectangle class, create two private attributes named lengthand width. Bothlength and widthshould 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'sperimeter 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

// Rectangle.cpp

using 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

}

Reference no: EM131984713

Questions Cloud

Write a c program that will deal with hotel reservations : Write a C program that will deal with reservations for a single night in a hotel with 3 rooms, numbered 1 to 3. It must use an infinite loop to read commands.
Trappings of knighthood : Group C should post reflect on what Cervantes is saying about the trappings of knighthood. For your post, tell us whether or not you agree
How can the information from public speaking : How can the information from PUBLIC SPEAKING, combined with information from other courses, training
What are the requirements for claiming dependent : What are the requirements for claiming dependent(s). Is the head of household filing status claimed by Al appropriate? Explain
Write public set methods to set values for length and width : Write public set methods to set the values for length and width. Write public get methods to retrieve the values for length and width.
How the relation of the spot and the forward price of oil : Show graphically how the relation of the spot and the forward price of oil is determined by the convenience yield on inventories.
What are the historical impacts of the presidents : What are the historical impacts of the presidents Wilson Woodrow and Reagan?
Argumentative essay or essay format example introduction : Argumentative Essay or essay format example introduction, body, and sources from books and peer view journals.
What effective annual rate can a bank earn on apr : What effective annual rate can a bank earn on an APR of 17%, compounded weekly?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd