static void Main(string[] args) { Student[] students = new Student[10]; char choice; int i = 0; do { Console.WriteLine("enter deatils of students: {0} \t ", i + 1); Console.Write("Enter the name of student : \t "); _name = Console.ReadLine(); Console.Write("Enter the Roll Number of student : \t "); _rollNumber = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter the address of student : \t "); _address = Console.ReadLine(); Console.Write("Enter the marks of student : \t "); _marks = Convert.ToInt32(Console.ReadLine()); students[i] = new Student(_name, _rollNumber,_address,_marks); i++; Console.WriteLine("want you to insert more data (y/n)"); choice = Convert.ToChar(Console.ReadLine()); }while(choice == 'y' || choice == 'Y'); for (int j = 0; j < i; j++) Console.WriteLine("{0} \t {1}", j + 1, students[j].Name); int UserChoiceWhose, UserChoiceWhat; Console.WriteLine("whose detail you want ..... enter choice in numeric \t :"); UserChoiceWhose = Convert.ToInt32(Console.ReadLine()) - 1; Console.Write("What detail you want \n\t 1. Name 2. marks\n\t 3. address \n\t 4. roll number \n\t 5. enrollment number"); UserChoiceWhat = Convert.ToInt32(Console.ReadLine()); switch (UserChoiceWhat) { case (int)StudentDetails.Name: Console.WriteLine(students[UserChoiceWhose].Name); break; case (int)StudentDetails.Marks: Console.WriteLine(students[UserChoiceWhose].Marks); break; case (int)StudentDetails.Address: Console.WriteLine(students[UserChoiceWhose].Address); break; case (int)StudentDetails.RollNumber: Console.WriteLine(students[UserChoiceWhose].RollNumber); break; case (int)StudentDetails.EnrollmentNumber: Console.WriteLine(students[UserChoiceWhose].EnrollmentNumber); break; } Console.ReadKey(); }
static void Main(string[] args) { Random random = new Random(); Student student = new Student("Karan",random.Next(1,Int32.MaxValue),"Manno",new int[]{76,65,58,70,69},"ABCInstitute",6); student.PrintAllDetails(); student.print(3); Console.ReadKey(); }
static void Main(string[] args) { int i; Student s1 = new Student(), s2 = new Student(), s3 = new Student(); Teacher t1 = new Teacher(), t2 = new Teacher(); Course ProgrammingWithCSharp = new Course("Programming with C#"); //set all students' name s1.FirstName = "S1_F"; s2.FirstName = "S2_F"; s3.FirstName = "S3_F"; s1.LastName = "S1_L"; s2.LastName = "S2_L"; s3.LastName = "S3_L"; //set all students' grades s1.EnterGrades(); s2.EnterGrades(); s3.EnterGrades(); //add all student to course class ProgrammingWithCSharp.AddStudent(s1); ProgrammingWithCSharp.AddStudent(s2); ProgrammingWithCSharp.AddStudent(s3); //add two teacher to course class ProgrammingWithCSharp.AddTeacher(t1); ProgrammingWithCSharp.AddTeacher(t2); //add course to degree Degree Bachelor = new Degree("Bachelor"); Bachelor.AddCourse(ProgrammingWithCSharp); //add degree to uprogram UProgram InformationTechnology = new UProgram("Information Technology"); InformationTechnology.AddDegree(Bachelor); //list students' name ProgrammingWithCSharp.ListStudents(); //list all students' grades s1.ListGrades(); s2.ListGrades(); s3.ListGrades(); Console.ReadLine(); }
public void AddStudent(Student s) { if (student_num >= SIZE) throw new IndexOutOfRangeException("Number of students can't be more than 3"); arr_student.Add(s); }