static void Main(string[] args) { Console.WriteLine("Enter your registration number: "); string regno = Console.ReadLine(); Console.WriteLine("Enter your name: "); string name = Console.ReadLine(); Console.WriteLine("Enter your department, SCI or COM: "); string depart = Console.ReadLine(); string dept = depart.ToUpper(); ScienceStudent sciencestudent = new ScienceStudent(regno, name, 75, 60, 80); CommerceStudent commercestudent = new CommerceStudent(regno, name, 71, 67, 55); if (dept == "SCI") { Console.WriteLine(sciencestudent.ToString()); } else if (dept == "COM") { Console.WriteLine(commercestudent.ToString()); } }
static void Main(string[] args) { Console.WriteLine("Enter Student Details: "); Console.WriteLine("Enter Student Name"); string StudentName = Console.ReadLine(); Console.WriteLine("Enter Student Registration Number: "); string StudentRegNumber = Console.ReadLine(); Console.WriteLine("Enter Department-- SCI or COM: "); string StudentDepartment = Console.ReadLine(); ScienceStudent sciencestudent = new ScienceStudent(StudentName, StudentRegNumber, 50, 65, 70); CommercialStudent commercialstudent = new CommercialStudent(StudentName, StudentRegNumber, 56, 70, 80); if (StudentDepartment == "SCI") { Console.WriteLine(sciencestudent.ToString()); } else if (StudentDepartment == "COM") { Console.WriteLine(commercialstudent.ToString()); } Console.WriteLine("Press any key to exit"); Console.ReadKey(); }
static void Main(string[] args) { Console.Write("Enter Department(Enter COM for Commercial Department and SCI for science department): "); string dept = Console.ReadLine(); if (dept == "SCI") { ScienceStudent student1 = new ScienceStudent(); student1.Department = dept; Console.Write("Enter Name: "); student1.Name = Console.ReadLine(); Console.Write("Enter Registration Number: "); student1.RegistrationNumber = Console.ReadLine(); student1.DisplayDetails(); } else if (dept == "COM") { CommerceStudent student1 = new CommerceStudent(); student1.Department = dept; Console.Write("Enter Name: "); student1.Name = Console.ReadLine(); Console.Write("Enter Registration Number: "); student1.RegistrationNumber = Console.ReadLine(); student1.DisplayDetails(); } }
static void GetData() { Console.WriteLine("Registration Number"); string reg = Console.ReadLine(); Console.WriteLine("Name"); string name = Console.ReadLine(); string dept; while (true) { Console.WriteLine("Enter 'SCI' for Computer Science or 'COM' for Commercial "); dept = Console.ReadLine(); if (dept == "SCI" || dept == "COM") { break; } } int num1; int num2; int num3; if (dept == "SCI") { Console.WriteLine("Enter score in Computer Network "); num1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter score in Data Structure "); num2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter score in C - Sharp "); num3 = Convert.ToInt32(Console.ReadLine()); } else { Console.WriteLine("Enter score in Electronic Circuits "); num1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter score in Circuit Analysis "); num2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter score in Analog Communication "); num3 = Convert.ToInt32(Console.ReadLine()); } if (dept == "SCI") { ScienceStudent newStudent = new ScienceStudent(reg, name, "Science", num1, num2, num3); Console.WriteLine(newStudent); } else { CommerceStudent newStudent = new CommerceStudent(reg, name, "Commercial", num1, num2, num3); Console.WriteLine(newStudent); } }