Answer to Question #289323 in C# for Kayla

Question #289323

Create a class representing a student. Include characteristics such as student number, first and last name, classification, and major. Write at least two constructors. Include properties for each of the data items. Include an instance method that returns a full name (with a space between first and last name). Create a second class (program.cs) that instantiated first class with information about yourself. In the second class, create a class (static) method that displays name and major using the instantiated object.

1
Expert's answer
2022-01-21T08:24:10-0500


using System;
using System.Collections.Generic;


namespace App
{
    class Student
    {


        private string number;


        public string Number
        {
            get { return number; }
            set { number = value; }
        }
        private string firstName;


        public string FirstName
        {
            get { return firstName; }
            set { firstName = value; }
        }
        private string lastName;


        public string LastName
        {
            get { return lastName; }
            set { lastName = value; }
        }
        private string classification;


        public string Classification
        {
            get { return classification; }
            set { classification = value; }
        }
        private string major;


        public string Major
        {
            get { return major; }
            set { major = value; }
        }


        public Student() { }


        public Student(string number, string firstName, string lastName, string classification, string major)
        {
            this.number = number;
            this.firstName = firstName;
            this.lastName = lastName;
            this.classification = classification;
            this.major = major;
        }


        public string fullName() {
            return firstName + " " + lastName;
        }
    }




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


            Student newStudent = new Student("456645", "Peter", "Smith", "junior", "Computer programming");


            display(newStudent);
            Console.ReadLine();


        }


        static void display(Student newStudent)
        {
            Console.WriteLine("The name of the student: {0}",newStudent.fullName());
            Console.WriteLine("The major of the student: {0}", newStudent.Major);
        }


    }
}

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