In: Computer Science
please write this in C #
Create a Patient class which has private fields for patientid, lastname,
firstname, age, and email. Create public properties for each of these private fields with get and
set methods. The entire lastname must be stored in uppercase. Create a main class which
instantiates a patient object and sets values for each data item within the class. Display the
data in the object to the console window.
Create a new C# console project with the name PatientInfo. Add the below code in respective files.
Patient.cs
using System;
namespace PatientInfo
{
    class Patient
    {
        //instance
variables
        private int
patientid;
        private string
lastname;
        private string
firstname;
        private int age;
        private string
email;
        //properties
        //propetry to get and
set the patient id
        public int
PatientId
        {
           
get
           
{
               
return patientid;
           
}
           
set
           
{
               
patientid = value;
           
}
        }
        //propetry to get and
set the lastname
        public string
LastName
        {
           
get
           
{
               
return lastname;
           
}
           
set
           
{
               
lastname = value.ToUpper(); //use ToUpper to convert the entire to
uppercase
           
}
        }
        //propetry to get and
set the firstname
        public string
FirstName
        {
           
get
           
{
               
return firstname;
           
}
           
set
           
{
               
firstname = value;
           
}
        }
        //propetry to get and
set the age
        public int Age
        {
           
get
           
{
               
return age;
           
}
           
set
           
{
               
age = value;
           
}
        }
        //propetry to get and
set the email
        public string
Email
        {
           
get
           
{
               
return email;
           
}
           
set
           
{
               
email = value;
           
}
        }
    }
}
Program.cs
using System;
namespace PatientInfo
{
    class Program
    {
        static void
Main(string[] args)
        {
           
//instantiate the patient object
           
Patient myPatient = new Patient();
           
//set values for each data item
           
myPatient.PatientId = 1122;
           
myPatient.LastName = "David";
           
myPatient.FirstName = "Lee";
           
myPatient.Age = 25;
           
myPatient.Email = "[email protected]";
           
//display the data in the object to the console
           
Console.WriteLine("Patient ID: " + myPatient.PatientId);
           
Console.WriteLine("Lastname: " + myPatient.LastName);
           
Console.WriteLine("Firstname: " + myPatient.FirstName);
           
Console.WriteLine("Age: " + myPatient.Age);
           
Console.WriteLine("Email: " + myPatient.Email);
           
Console.Write("\nPress any to exit..");
           
Console.ReadKey();
        }
    }
}
Output:

Code screenshot:




Let me know if you have any concerns with the above solution.