0

can someone convert this c++ code to C# code... I'm very new to C# pls help

the main.cpp

```
// Main Program
//
#include "square.h" // Derived Class square
int main()
{
//*******************************************************************************
cout << "\t\t\t+y";
cout << "\n\t\t\t +";
cout << "\n\t\t\t +" << "\tpoint a" << "\t\t\t\tpoint b";
cout << "\n\t\t\t +" << "\t ax,ay" << "\t\t\t\t bx,by";
cout << "\n\t\t\t +";
cout << "\n\t\t\t +";
cout << "\n\t\t\t +" << "\t\t\t point e";
cout << "\n\t\t\t +" << "\t\t\t ex,ey";
cout << "\n\t\t\t +";
cout << "\n\t\t\t +";
cout << "\n\t\t\t +" << "\tpoint c" << "\t\t\t\tpoint d";
cout << "\n\t\t\t +" << "\t cx,cy" << "\t\t\t\t dx,dy";
cout << "\n\t\t\t +";
cout << "\n\t\t\t +";
cout << "\n\t\t\t + + + + + + + + + + + + + + + + +";
cout << "\n\t\t\t0.0" << "\t\t\t\t\t\t\t\t +x";
cout << "\n\t\t\t\tCartesian Coordinate System";
cout << "\n";
cout << "\nPoint a is upper left, b is upper right" << endl;
cout << "c is lower left, d if lower right" << endl;
cout << "\nSide a is ad, b is ba, c is bd and d is dc" << endl;
cout << "\nDiagonal a is cb, Diagonal b is ad" << endl;
cout << "************************************************************" << endl;
cout << "For a rectangle use points 4,12,11,5,-12,-4,-5,-11" << endl;
cout << "\nFor a square use points 1,9,8,2,-6,2,1,-5" << endl;
cout << "************************************************************" << endl;
Square Square_Results;
Square_Results.Square_Data();
return 0;
}
```

the quad.h

```
// Base Class Quadrilateral
//
// //*************************************************************
//The program will use cartesian coordinate system,
//The axises will be x,y as follows:
//
//
// ............................+
//................... +y.... +.. point a ..........side_a ..........point b
// ............................+.. ax,ay .......................................bx,by
//............................ +
// ............................+
// ............................+ ..side_c........... point e ...........side_b
// ............................+............................. ex,ey
// ............................+
//............................ +
//............................ + ..point c............ side d ...........point d
// ............................+ ..cx,cy ........................................dx,dy
// ............................+
// ............................+ + + + + + + + + + + + + + + + + +
// ..........................0.0............................................... +x
// Point a is upper left *** side_a is between points a and c
// Point b is upper right *** side_b is between points a and b
// Point c is lower left *** side_c is between points b and d
// Point d is lower right *** side_d is between points c and d
//
// *************************************************************
#include<iostream>
#include <cmath> // Needed fo "fabs" & "sqrt" functions
using namespace std;
class Quadrilateral
{
public:
// Declare coordinate point variables
float ax, ay, bx, by, cx, cy, dx, dy; // Corner points
Quadrilateral() // Default constructor
{
// Initialize variables to 0 ax = ay = bx = by= cx = cy = dx = dy = 0;
// Enter coordinate data points for corners
cout << "\nEnter coordinate ax: ";
cin >> ax;
cout << "Enter coordinate ay: ";
cin >> ay;
cout << "Enter coordinate bx: ";
cin >> bx;
cout << "Enter coordinate by: ";
cin >> by;
cout << "Enter coordinate cx: ";
cin >> cx;
cout << "Enter coordinate cy: ";
cin >> cy;
cout << "Enter coordinate dx: ";
cin >> dx;
cout << "Enter coordinate dy: ";
cin >> dy; };
// removed the curley brace
~Quadrilateral() // Call Destructor
{
cout << "\n\nThe Base Class Rectangle has been destroyed!" << endl;
};
};
```

the rect.h

```
//
//DERIVED CLASS RECTANGLE
//*************************************************************
//
//Derived Class rect.h
#include <iomanip>
#include "quad.h" // Base Class file
class Rectangle : public Quadrilateral // Inherit from Class Quadrilateral
{
public:
float dx1, dy1, dx2, dy2, dx3, dy3, dx4, dy4; // differences
double side_a, side_b, side_c, side_d;
double diagonal_a, diagonal_b; // Diagonals
int typeo; // Type of Figure
double area;
double diag_diff;
Rectangle() // Default constructor
{
// Initialize variables to 0
area= 0;
cout << "\n********************" << endl;
// Calculate sides - dxn and dyn are x and y components
cout << "\n\tCalculating Sides and x/y Components" << endl;
dy1= ay - cy;
cout << "\ndy1= " << dy1;
dx1= ax - cx;
cout << "\ndx1= " << dx1;
side_a= sqrt(dx1 * dx1 + dy1 * dy1);
cout << "\nSide a = " << side_a;
dy2= by - ay;
cout << "\n\ndy2= " << dy2;
dx2= bx - ax;
cout << "\ndx2= " << dx2;
side_b= sqrt(dx2 * dx2 + dy2 * dy2);
cout << "\nSide b = " << side_b;
dy3= dy - by;
cout << "\n\ndy3= " << dy3;
dx3= dx - bx;
cout << "\ndx3= " << dx3;
side_c= sqrt(dx3 * dx3 + dy3 * dy3);
cout << "\nSide c = " << side_c;
dy4= dy - cy;
cout << "\n\ndy4= " << dy4;
dx4= dx - cx;
cout << "\ndx4= " << dx4;
side_d= sqrt(dx4 * dx4 + dy4 * dy4);
cout << "\nSide d = " << side_d;
cout << "\n\n********************" << endl;
// Calculate diagonals to check for rectangle
cout << "\n\tCalculating Diagonals" << endl;
diagonal_a = sqrt (side_a * side_a + side_b * side_b);
diagonal_b = sqrt (side_c * side_c + side_d * side_d);
diag_diff= fabs(diagonal_a - diagonal_b);
cout << "\nDiagonal a= " << diagonal_a
<< "\t\tDiagonal b= " << diagonal_b
<< "\nDifference= " << diag_diff << endl;
if (diag_diff == 0)
{
cout << "\n***********************************" << endl;
cout << "\tPlane Figure is a Rectangle!" << endl;
cout << "Diagonal difference zero" << endl;
cout << "Side a= " << side_a << "\t\tSide b= " << side_b << endl;
area = side_a * side_b; // Calculate the area
cout << "The Area of the Rectangle is = " << area << endl;
}
else
if (diag_diff < 0.0001)
{
cout << "\n***********************************" << endl;
cout << "\tPlane Figure is approximately a Rectangle!" << endl;
cout << "Diagonal difference less than 0.0001" << endl;
cout << "Side a= " << side_a << "\t\tSide b= " << side_b << endl;
area = side_a * side_b; // Calculate the area
cout << "The Area of the Rectangle is = " << area << endl;
}
else
{
cout << "\n\n\tPlane Figure is NOT a Rectangle!" << endl;
cout << "Diagonal difference greater than 0.0001" << endl;
}
};
~Rectangle() { }; // Call Destructor
};
```

and the square.h

```
//
//DERIVED CLASS SQUARE
//
//*************************************************************
//Devived Class square.h
# include "rect.h" // Base Class file
class Square : Rectangle // Inherit from Class Rectangle
{
private:
// Declare coordinate point variables
float ex, ey;
public:
Square() // Default constructor
{
// Initialize variables to 0
ex= 0;
ey= 0;
};
~Square() { }; // Call Destructor
// Test for Square, Calculate Center Points and Display results
void Square_Data()
{
// Calculate sides - dxn and dyn are x and y components
dy1= ay - cy;
dx1= ax - cx;
side_a= sqrt(dx1 * dx1 + dy1 * dy1);
dy2= by - ay;
dx2= bx - ax;
side_b= sqrt(dx2 * dx2 + dy2 * dy2);
dy3= dy - by;
dx3= dx - bx;
side_c= sqrt(dx3 * dx3 + dy3 * dy3);
dy4= dy - cy;
dx4= dx - cx;
side_d= sqrt(dx4 * dx4 + dy4 * dy4);
// Calculate diagonals to check for rectangle
diagonal_a = sqrt (side_a * side_a + side_b * side_b);
diagonal_b = sqrt (side_c * side_c + side_d * side_d);
if ((diag_diff < 0.0001) && (fabs(side_a - side_b) < 0.0001))
{
ex= bx - (bx - cx)/2;
ey= ay - (ay - dy)/2;
cout << "\n***********************************" << endl;
cout << "\tPlane Figure is a Square!" << endl;
cout << "Side = " << side_a << endl;
cout << "Center Coordinates of the Square are: (" << ex << "," << ey << ")" << endl; }
else
{
cout << "\n***********************************" << endl;
cout << "\n\tObject is not a Square!" << endl;
}
};
};
```