Create an application that will take 5 employees data and print the data.take a skill name and print all the employee who have skill
using System;
public class Employee
{
public string name;
public int age;
public string skill;
public Employee(string name, int age, string skill)
{
this.name = name;
this.age = age;
this.skill = skill;
}
public void Print()
{
Console.WriteLine($"Name: {name}");
Console.WriteLine($"Age: {age}");
Console.WriteLine($"Skill: {skill}");
}
}
public class HelloWorld
{
public static void Main(string[] args)
{
Employee[] employees = new Employee[5];
for(int i = 0; i < employees.Length; i++)
{
Console.WriteLine($"Number employee: {i + 1}");
employees[i] = new Employee("", 0, "");
Console.Write("Enter name: ");
employees[i].name = Console.ReadLine();
Console.Write("Enter age: ");
employees[i].age = int.Parse(Console.ReadLine());
Console.Write("Enter skill: ");
employees[i].skill = Console.ReadLine();
}
for(int i = 0; i < employees.Length; i++)
{
Console.WriteLine($"Number employee: {i + 1}");
employees[i].Print();
}
Console.Write("Enter skill employee: ");
string nameSkill = Console.ReadLine();
for(int i = 0; i < employees.Length; i++)
{
if(employees[i].skill == nameSkill)
{
Console.WriteLine($"Number employee: {i + 1}");
employees[i].Print();
}
}
}
}
Comments
Leave a comment