Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Im stuck on this assignment im supposed to set the sName, iAreaCode, and iPhoneN

ID: 3723155 • Letter: I

Question

Im stuck on this assignment im supposed to set the sName, iAreaCode, and iPhoneNumber property. I know in order to do this you need to use the "get set" above the main method.

Please help in C#

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

Telephone person = new Telephone();

string sName;
int iAreaCode;
int iPhoneNumber;


Console.Write("Please Enter Person's Name: ");
sName = Console.ReadLine().Trim();
  
// Set Name property here

Console.Write("Please enter the area code: ");
int.TryParse(Console.ReadLine().Trim(), out iAreaCode);
  
// Set AreaCode property here

Console.Write("Please enter the number: ");
int.TryParse(Console.ReadLine().Trim(), out iPhoneNumber);
  
// Set Number property here

Console.WriteLine(" ");

Console.WriteLine("Contact Information:");
Console.WriteLine("====================");
Console.WriteLine("Name: {0} Telephone number: {1}-{2} ", ); // ** Complete this line using properties
  
Console.Write("Press any key to exit...");
Console.ReadKey();

}
}
}

Explanation / Answer

using System;

namespace myProgram

{

    class Program

    {

        public string sName;

        public int iAreaCode;

        public int iPhoneNumber;

       

        Program()

        {

            this.sName = "";

            this.iAreaCode = 0;

            this.iPhoneNumber = 0;

        }

       

        public void setSName(string sName)

        {

            this.sName = sName;

        }

       

        public void setIAreaCode(int iAreaCode)

        {

            this.iAreaCode = iAreaCode;

        }

       

        public void setIPhoneNumber(int iPhoneNumber)

        {

            this.iPhoneNumber = iPhoneNumber;

        }

       

        public string getSName()

        {

            return this.sName;

        }

       

        public int getIAreaCode()

        {

            return this.iAreaCode;

        }

       

        public int getIPhoneNumber()

        {

            return this.iPhoneNumber;

        }

       

        static void Main(string[] args)

        {

            Program ob = new Program();

   

            Console.Write("Please Enter Person's Name: ");

           

            // Set Name property here

            ob.setSName(Console.ReadLine().Trim());

            Console.Write("Please enter the area code: ");

            int temp;

            int.TryParse(Console.ReadLine().Trim(), out temp);

           

            

            // Set AreaCode property here

            ob.setIAreaCode(temp);

            Console.Write("Please enter the number:     ");

           

            int.TryParse(Console.ReadLine().Trim(), out temp);

           

            // Set Number property here

            ob.setIPhoneNumber(temp);

        }

    }

}