Question #45145

1. Write a program that computes the perimeter and the area of a rectangle. Define your own values for the length and width. (Assuming that L and W are the length and width of the rectangle, Perimeter = 2*(L+W) and Area = L*W. Display the output on the screen using dbms_output.put_line.
1

Expert's answer

2014-08-27T12:18:22-0400

Answer on Question #45145, Engineering, Other

Task: Write a program that computes the perimeter and the area of a rectangle. Define your own values for the length and width. (Assuming that L and W are the length and width of the rectangle, Perimeter = 2*(L+W) and Area = L*W.

Solution:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication30

{

class Rectangle

{

double Length, Width;

double area;

public Rectangle(double L, double W)

{

Length = L;

Width = W;

}

public double Area(double L, double W)

{

return L * W;

}

public double Perimeter(double L, double W)

{

return 2 * (L + W);

}

}

```

class Program

{

static void Main(string[] args)

{

double L, W;

Console.Write("Enter Length: ");

L = double.Parse( Console.ReadLine());

Console.Write("Enter Width: ");

W = double.Parse(Console.ReadLine());

}

Rectangle r = new Rectangle(L,W);

Console.WriteLine("Area of Rectangle:" + r.Area(L,W));

Console.WriteLine("Perimeter of Rectangle:" + r.Perimeter(L, W));

Console.ReadLine();

}

http://www.AssignmentExpert.com/


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!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS