Answer to Question #264565 in C# for Shreenidhi

Question #264565

Create a class Person with attributes string Name, string Address and int age and define getter setter




method using Auto Implementation Property




• Create a class PersonImplementation and implement the below given methods:




1. GetName(IList<Person> person) display the name and address of all the persons in the List




2. Average(List<Player> players) to calculate the




average age of all the persons.




3. Max(IList<Player> players) to find the maximum age of the person.

1
Expert's answer
2021-11-12T16:31:55-0500
 class Person
    {
        public string Name { get; set; }
        public string Address { get; set; }
        public int Age { get; set; }
    }


    class PersonImplementation
    {
        public void GetName(IList<Person> persons)
        {
            foreach (Person person in persons)
            {
                Console.WriteLine($"{person.Name} - {person.Address}");
            }
        }


        public void Average(List<Person> persons)
        {
            Console.WriteLine($"Average age of persons: {persons.Average(p => p.Age)}");
        }


        public void Max(IList<Person> persons)
        {
            Console.WriteLine($"Average age of persons: {persons.Max(p => p.Age)}");
        }
    }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS