Write a program in C#.net- to demonstrate object oriented concept: Design user Interface.

1 year ago
Cloud Computing

1)namespace CLASS_DEMO

{

class person

{

private string name; int age;

double salary; public void getdata()

{

Console.Write("Enter Your Name:-"); name = Console.ReadLine(); Console.Write("Enter the age:-");

age = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter the salary:-");

salary = Convert.ToDouble(Console.ReadLine());

}

public void putdata()

{

Console.WriteLine("NAME==>" + name); Console.WriteLine("AGE==>" + age); Console.WriteLine("SALARY==>" + salary);

}

}

class Program

{

static void Main(string[] args)

{

person obj = new person(); obj.getdata(); obj.putdata(); Console.ReadLine();

}

}

}

2) namespace single_inheritance

{

class Animal

{

public void Eat()

{

Console.WriteLine("Every animal eats something.");

}

public void dosomething()

{

Console.WriteLine("Every animal does something.");

}

}

class cat : Animal

{

static void Main(string[] args)

{

cat objcat = new cat(); objcat.Eat(); objcat.dosomething(); Console.ReadLine();

}

}

}

3) namespace Method_Overloading_1

{

class Area

{

static public int CalculateArea(int len, int wide)

{

return len * wide;

}

static public double CalculateArea(double valone, double valtwo)

{

return 0.5 * valone * valtwo;

}

}

class Program

{

static void Main(string[] args)

{

int length = 10; int breath = 22;

double tbase = 2.5; double theight = 1.5;

Console.WriteLine("Area of Rectangle:-" + Area.CalculateArea(length, breath)); Console.WriteLine("Area of triangle:-" + Area.CalculateArea(tbase, theight)); Console.ReadLine();

}

}

}

0
Dipti KC
Dec 19, 2022
More related questions

Questions Bank

View all Questions