Answer to Question #231609 in C# for Mandisa

Question #231609
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-08-31T05:58:58-0400
using System;

namespace ConsoleApplication1
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var John = new Member("John");
            var Susan = new Member("Susan");
            John.setPoints(10);
            Susan.setPoints(5);
            if (John.getPoints() > Susan.getPoints())
            {
                Console.WriteLine(John.getName());
            }
            else if (Susan.getPoints() > John.getPoints())
            {
                Console.WriteLine(Susan.getName());
            }
            else
            {
                Console.WriteLine($"Equals for {John.getName()} and {Susan.getName()}");
            }
        }
    }

    class Member
    {
        private string Name;
        private int Points;

        public string getName()
        {
            return Name;
        }

        public int getPoints()
        {
            return Points;
        }

        public void setPoints(int P)
        {
            Points = P;
        }
        
        public Member(string name, int points=0)
        {
            Name = name;
            setPoints(points);
        }
    }
}

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