10. Write a program that would print the information (name, year of joining, salary, address) of three employees by creating a class named 'Employee'. The output should be as follows:
Name Year of joining Address
Robert 1994 64C- WallsStreat
Sam 2000 68D- WallsStreat
John 1999 26B- WallsStreat
C#
using System;
namespace information
{
class Program
{
class Employee
{
public string name;
public int year;
public double salary;
public string adress;
public void print()
{
Console.WriteLine("{0,6}{1,10}{2,20}", name, year, adress);
}
}
public static void Main(string[] args)
{
Employee[] emploee = new Employee[3];
emploee[0] = new Employee();
emploee[0].name = "Robert";
emploee[0].year = 1994;
emploee[0].salary = 200000;
emploee[0].adress = "64C- WallsStreat";
emploee[1] = new Employee();
emploee[1].name = "Sam";
emploee[1].year = 2000;
emploee[1].salary = 1000000;
emploee[1].adress = "68D- WallsStreat";
emploee[2] = new Employee();
emploee[2].name = "John";
emploee[2].year = 1999;
emploee[2].salary = 150000;
emploee[2].adress = " 26B- WallsStreat";
Console.WriteLine("\nEmployee:\n");
Console.WriteLine("{0,4}{1,18}{2,10}", "Name", "Year of joining", "Address");
emploee[0].print();
emploee[1].print();
emploee[2].print();
Console.Write("\nPress any key to continue . . . ");
Console.ReadKey(true);
}
}
}
Comments
Leave a comment