Answer to Question #232816 in C# for Phamela

Question #232816

Create a console application for a club to record their member information. For each member to need to store the member’s name and merit points. All new members starts with 0 merit points. Implement class Member which has private attributes for Name and Points. You need to create at a constructor method and the class also needs to have the following methods: public string getName() //Returns the name of the member public int getPoints() //Returns the points of the member public void setPoints(int P) //Sets the points of the member In the application class (main method in the program.cs file), do the following:  Create two instances of Member, for John and Susan  Assign merit points to each of them  Use an if statement to display the name of the member with the highest points. 


1
Expert's answer
2021-09-03T15:05:54-0400
 class Program
    {
        static void Main()
        {
            Member memberJonh = new Member("Jonh");
            Member memberSusan = new Member("Susan");


            memberJonh.setPoints(50);
            memberSusan.setPoints(30);


            if (memberJonh.getPoints() > memberSusan.getPoints())
                Console.WriteLine("{0} has more points",memberJonh.getName());
            else
                Console.WriteLine("{0} has more points", memberSusan.getName());


            Console.ReadKey();
        }
    }


    class Member
    {
        string Name;
        int Point;


        public Member(string name)
        {
            Name = name;
        }


        public string getName()
        {
            return Name;
        }


        public int getPoints()
        {
            return Point;
        }


        public void setPoints(int P)
        {
            Point = P;
        }
    }

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