Answer to Question #233934 in C# for Phamela

Question #233934

Create a console application for the department to record information for students who receive bursaries in the department. For each recipient you need to store the recipient’s name and the number of hours outstanding. Most new recipients start with 90 hours, but there are some exceptions. As recipients works in the department, the number of hours left needs to be updated (decreased) from time to time, based on hours already worked. Implement class Recipient which has private attributes for Name and Hours. Create two constructors, one with a default allocation of 90 hours for a recipient, and the other should accept the number of hours for a recipient. In addition to the constructors, the class should have the following methods: 


1
Expert's answer
2021-09-06T16:23:29-0400




using System;
namespace RecipientApp
{
    class Recipient
    {


        private string Name;
        private int Hours;


        public Recipient(string Name)
        {
            this.Name = Name;
            this.Hours = 90;
        }


        public Recipient(string Name, int Hours)
        {
            this.Name = Name;
            this.Hours = Hours;
        }




        //Returns the name of the recipient
        public string getName()
        {
            return Name;
        }




        //Returns the hours outstanding
        public int getHours()
        {
            return Hours;
        }


        //Set the hours outstanding
        public void setHours(int H)
        {
            this.Hours = H;
        }


        
        //Display the name and number of hours left for a recipient
        public void displayRecipient()
        {
            Console.WriteLine("Name: {0} ", Name);
            Console.WriteLine("{0} hours left for a recipient", Hours);
        }
    }




    class Program
    {
        static void Main(string[] args)
        {


            Recipient XolaRecipient = new Recipient("Xola");
            Recipient DavidRecipient = new Recipient("David");
            Recipient SandyRecipient = new Recipient("Sandy");
            XolaRecipient.setHours(20);
            DavidRecipient.setHours(10);
            SandyRecipient.setHours(16);
            XolaRecipient.displayRecipient();
            DavidRecipient.displayRecipient();
            SandyRecipient.displayRecipient();


            Console.ReadLine();
        }
    }
}






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