What do you call those statements highlighted in red?
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
int choice;
Console.WriteLine("Please select below");
Console.WriteLine();
Console.WriteLine("1. Area of a Circle");
Console.WriteLine("2. Area of a Rectangle");
Console.WriteLine("3. Area of a Cylinder");
Console.WriteLine();
choice = Convert.ToInt32(Console.ReadLine());
if (choice == 1)
{
Console.Clear();
aCircle();
}
if (choice == 2)
{
Console.Clear();
aRectangle();
}
if (choice == 3)
{
Console.Clear();
aCylinder();
}
Console.Write("Do you wish to try again? : ");
Console.ReadLine();
}
static void aCircle()
{
int r;
double A;
Console.WriteLine("Enter the radius:");
r = Convert.ToInt32(Console.ReadLine());
A = 3.14 * r * r;
Console.WriteLine("The Area of circle of given radius is="+A);
Console.ReadLine();
}
static void aRectangle()
{
int w, h;
int ar;
Console.WriteLine("Enter the width:");
w = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the height:");
h = Convert.ToInt32(Console.ReadLine());
ar = w * h;
Console.WriteLine("The Area of rectangle is=" + ar);
}
static void aCylinder()
{
double rc;
double hc;
double ac;
double pi=3.14;
Console.WriteLine("Enter the radius");
rc = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the height:");
hc = Convert.ToInt32(Console.ReadLine());
ac = 2 * pi * rc*rc + 2 * pi * rc * hc;
Console.WriteLine("The Area of cylinder is=" + ac);
Console.ReadLine();
}
}
}
Another question.
This is an example of a constructor method:
public double multiply(double nFirst, double nSecond)
{
}
now what makes it a constructor method and how is it different from a normal method?