63 034
Assignments Done
Successfully Done
In July 2018

Answer to Question #1581 in C# for CALEB ADEYMO

Question #1581
Want to write a C# progm creating a Rectangle class to have two variables length and width. Two constructors are needed, the default constructor should intialize length and width to 1.0 each. The second must pass in two values to initialize length and width. There must be six methods to do the following: SetLength,SetWidth,GetLength,GetWidth, GetArea, and GetPerimeter.The perimeter is the sum of all sides of a rectangle. Three instances of the Rectangle needs to be created. The first rectOne must use the se
Expert's answer
using System;namespace Application
public class Rectangle
private double length;
private double width;

public Rectangle ()
length = 1.0;
width = 1.0;

public Rectangle (double l,double w)
length = l;
width = w;

public void SetLength(double l){
length = l;

public void SetWidth(double w){
width = w;

public double GetLength(){
return length;

public double GetWidth(){
return width;

public double GetArea(){
return length*width;

public double GetPerimeter(){
return (length+width)*2;

static void Main(string[] args){
Rectangle rectOne = new Rectangle();
Console.WriteLine("Area: "+rectOne.GetArea());
Console.WriteLine("Perimeter: "+rectOne.GetPerimeter());
Rectangle rectTwo = new Rectangle(2.0,4.0);
Console.WriteLine("Area: "+rectTwo.GetArea());
Console.WriteLine("Perimeter: "+rectTwo.GetPerimeter());
Rectangle rectThree = new Rectangle(5.0,10.0);
Console.WriteLine("Area: "+rectThree.GetArea());
Console.WriteLine("Perimeter: "+rectThree.GetPerimeter());

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


Assignment Expert
21.06.11, 16:29

You are always welcome!

Assignment Expert
21.06.11, 16:24

We have a lot of experts ready for helping you.

Assignment Expert
21.06.11, 16:22


Leave a comment

Ask Your question

Privacy policy Terms and Conditions