Answer to Question #187782 in C# for CHANDRASENA REDDY

Question #187782

St. Joseph school planned to create a system to store the records of students studying in their school. They need to store various kinds of data about their students. Write a C# program based on the class diagram given below and initialize the variables with proper values and print it


SCHOOL DEMO:

rollNumber : int

studentName : string

age : bytr

gender : char

dateOfBirth : DateTime

address : string

precentage : float

_______________

+Main(string[] args)



1
Expert's answer
2021-05-02T13:45:54-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace C_SHARP
{
    class Program
    {
        class Student
        {
            private int rollNumber;
            private string studentName;
            private byte age;
            private char gender;
            private DateTime dateOfBirth;
            private string address;
            private float precentage;


            public Student() { }
            /// <summary>
            /// Constructor
            /// </summary>
            /// <param name="rollNumber"></param>
            /// <param name="studentName"></param>
            /// <param name="age"></param>
            /// <param name="gender"></param>
            /// <param name="dateOfBirth"></param>
            /// <param name="address"></param>
            /// <param name="precentage"></param>
            public Student(int rollNumber, string studentName, byte age, char gender, DateTime dateOfBirth, string address, float precentage)
            {
                this.rollNumber = rollNumber;
                this.studentName = studentName;
                this.age = age;
                this.gender = gender;
                this.dateOfBirth = dateOfBirth;
                this.address = address;
                this.precentage = precentage;
            }
            /// <summary>
            /// Displays info
            /// </summary>
            public void display() {
                Console.WriteLine("Roll number: {0}", this.rollNumber);
                Console.WriteLine("Student name: {0}", this.studentName);
                Console.WriteLine("Age: {0}", this.age);
                Console.WriteLine("Gender: {0}", this.gender);
                Console.WriteLine("Date of Birth: {0}", this.dateOfBirth);
                Console.WriteLine("Address: {0}", this.address);
                Console.WriteLine("Precentage: {0}", this.precentage);
            }
        }


        static void Main(string[] args)
        {


            Student student1 = new Student(1, "Peter Smith", 25, 'M', new DateTime(1990, 5, 15), "Address", 59);
            Student student2 = new Student(2, "Mary Clark", 22, 'F', new DateTime(1991, 4, 25), "Main Road 25", 70);
            student1.display();
            Console.WriteLine();
            student2.display();
            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