Lab_Sheet_4_Method Overloading N Inheritance
Lab_Sheet_4_Method Overloading N Inheritance
namespace myfirstproject
{
internal class overloading
{
static void area(int a, int b)
{
Console.WriteLine("area of triangle is=" + ((a * b) / 2));
}
static void area(int a)
{
Console.WriteLine("area of square is=" + (a * a));
}
static void area(int a, double b)
{
Console.WriteLine("area of rectangle is=" + (a * b));
}
static void Main(string[] args)
{
overloading.area(8, 5);
overloading.area(5);
overloading.area(6, 8.7);
Console.ReadKey();
}
}
Assessment 4a:
Write a C# Program to find out the multiplication of two, three and four operands using
method overloading.
2. Create a Class called Rectangle and store length, width using constructor.
Calculate the area using that. Create tabletop using rectangle class and calculate
the cost of painting that table top. (Use single inheritance)
namespace myfirstproject
{
class Rectangle
{
protected double length, width;
protected double calcarea;
protected Rectangle()
{
length = 0;
width = 0;
}
Create a class called Employee with id and salary. Employee class is inheriting from
Human class. Name and age should be defined in Human class. Include display method
in Employee class to display all details.