Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ModuleThreeAssignment
- {
- class Program
- {
- //The structure for student
- public struct Student
- {
- public Student(string name, string currentDegree, string age, double gpa)
- {
- this.Name = name;
- this.CurrentDegree = currentDegree;
- this.Age = age;
- this.Gpa = gpa;
- }
- public string Name;
- public string CurrentDegree;
- public string Age;
- public double Gpa;
- }
- //The structure for Teacher
- public struct Teacher
- {
- public Teacher(string name, string qualification, int age, string department)
- {
- this.Name = name;
- this.Qualiffication = qualification;
- this.Age = age;
- this.Department = department;
- }
- public string Name;
- public string Qualiffication;
- public int Age;
- public string Department;
- }
- //The structure for program
- public struct ProgramInf
- {
- public ProgramInf(string name, DateTime startDate, DateTime endDate, int freePlaces)
- {
- this.Name = name;
- this.StartDate = startDate;
- this.EndDate = endDate;
- this.FreePlaces = freePlaces;
- }
- public string Name;
- public DateTime StartDate;
- public DateTime EndDate;
- public int FreePlaces;
- }
- //The structure for Course
- public struct Course
- {
- public Course(string name, string professor, string department, int credits, string semester)
- {
- this.Name = name;
- this.Professor = professor;
- this.Department = department;
- this.Credits = credits;
- this.Semester = semester;
- }
- public string Name;
- public string Professor;
- public string Department;
- public int Credits;
- public string Semester;
- }
- //The Main
- static void Main(string[] args)
- {
- Console.WriteLine("Please select the type of information you want to receive: student, teacher, program, course");
- string input = Console.ReadLine();
- if (input == "student")
- {
- StudentInformation();
- }
- else if (input == "teacher")
- {
- TeacherInformation();
- }
- else if (input == "program")
- {
- GetProgramInformation();
- }
- else if(input == "course")
- {
- GetCourseInformation();
- }
- }
- //Group of methods for student
- static void StudentInformation()
- {
- Console.Write("Enter the name: ");
- string name = Console.ReadLine();
- Console.Write("Enter the degree: ");
- string degreeStudent = Console.ReadLine();
- Console.Write("Enter the age: ");
- string age = Console.ReadLine();
- Console.Write("Enter the GPA: ");
- double gpa = double.Parse(Console.ReadLine());
- Student student1 = new Student(name, degreeStudent, age, gpa);
- Console.WriteLine("If you want to check how my array works type: check array. Else just type something other like \"no\"");
- string input1 = Console.ReadLine();
- if (input1 == "check array")
- {
- Student[] studentArray = new Student[1];
- studentArray[0] = student1;
- foreach (var student in studentArray)
- {
- Console.WriteLine("{0} is persuading a degree in {1} and is {2} years-old. Current GPA: {3}", student.Name, student.CurrentDegree, student.Age, student.Gpa);
- }
- }
- else
- {
- PrintStudentInformation(student1.Name, student1.CurrentDegree, student1.Age, student1.Gpa);
- }
- }
- static void PrintStudentInformation(string name, string degree, string age, double gpa)
- {
- Console.WriteLine("{0} is persuading a degree in {1} and is {2} years-old. Current GPA: {3}", name, degree, age, gpa);
- }
- //Group of methods for teacher
- static void TeacherInformation()
- {
- Console.Write("Enter the name: ");
- string name = Console.ReadLine();
- Console.Write("Enter the qualification: ");
- string qualification = Console.ReadLine();
- Console.Write("Enter the age: ");
- int age = int.Parse(Console.ReadLine());
- Console.Write("Enter the Department: ");
- string department = Console.ReadLine();
- Teacher teacher1 = new Teacher(name, qualification, age, department);
- PrintTeacherInformation(teacher1.Name, teacher1.Qualiffication, teacher1.Age, teacher1.Department);
- }
- static void PrintTeacherInformation(string name, string qualification, int age, string department)
- {
- Console.WriteLine("Name: {0}, Qualification: {1}, Age: {2}, Department: {3}", name, qualification, age, department);
- }
- //Group of Methods for Program
- static void GetProgramInformation()
- {
- try
- {
- Console.Write("Enter the name: ");
- string name = Console.ReadLine();
- Console.Write("Enter the Start Date (DD/MM/YYYY): ");
- DateTime start = Convert.ToDateTime(Console.ReadLine());
- Console.Write("Enter the End Date (DD/MM/YYYY): ");
- DateTime end = Convert.ToDateTime(Console.ReadLine());
- Console.Write("Enter the number of Free Places: ");
- int freePlaces = int.Parse(Console.ReadLine());
- ProgramInf programInf1 = new ProgramInf(name, start, end, freePlaces);
- PrintProgramInformation(programInf1.Name, programInf1.StartDate, programInf1.EndDate, programInf1.FreePlaces);
- }
- catch (System.FormatException e)
- {
- Console.WriteLine("Please input the Start and End dates in the valid format!!!");
- }
- }
- static void PrintProgramInformation(string name, DateTime start, DateTime end, int free)
- {
- Console.WriteLine("Name: {0}, Start: {1}, End: {2}, Free Places: {3}", name, start.ToString(), end.ToString(), free.ToString());
- }
- //The Group of Methods for Course
- static void GetCourseInformation()
- {
- Console.Write("Enter the name: ");
- string name = Console.ReadLine();
- Console.Write("Enter the professor: ");
- string professor = Console.ReadLine();
- Console.Write("Enter the department: ");
- string department = Console.ReadLine();
- Console.Write("Enter the number of credits: ");
- int credits = int.Parse(Console.ReadLine());
- Console.Write("Enter the semester, the program is offered: ");
- string semester = Console.ReadLine();
- Course course1 = new Course(name, professor, department, credits, semester);
- PrintCourseInformation(course1.Name, course1.Professor, course1.Department, course1.Credits, course1.Semester);
- }
- static void PrintCourseInformation(string name, string professor, string department, int credits, string semester)
- {
- Console.WriteLine("Name: {0}, Professor: {1}, Department: {2}, Number of Credits it is evaluated: {3}, Semester it is offered: {4}", name, professor, department, credits.ToString(), semester);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment