static void Main(string[] args) { Student firstStudentObject = new Student(); firstStudentObject.StudentLastName = AskForStudentName("Last"); firstStudentObject.StudentFirstName = AskForStudentName("First"); firstStudentObject.StudentNumber = AskForStudentNumber(); firstStudentObject.Major = AskForMajor(firstStudentObject.StudentFirstName); firstStudentObject.Score1 = AskForExamScore(1); firstStudentObject.Score2 = AskForExamScore(2); firstStudentObject.Score3 = AskForExamScore(3); Console.Clear(); Console.WriteLine("First Student"); Console.WriteLine(firstStudentObject.ToString()); Student secondStudentObject = new Student("2345"); secondStudentObject.Score1 = 95; secondStudentObject.Score2 = 62; secondStudentObject.Score3 = 87; Console.WriteLine("\n\nSecond Student"); Console.WriteLine("Student Number: " + secondStudentObject.StudentNumber + "\nAverage: {0:F1}", secondStudentObject.CalculateAverage()); Student thirdStudentObject = new Student("5432", "Randolph", "Wonder"); thirdStudentObject.Major = "Math"; thirdStudentObject.Score1 = 95; thirdStudentObject.Score2 = 87; thirdStudentObject.Score3 = 72; Console.WriteLine("\n\nThird Student"); Console.WriteLine(thirdStudentObject); Student aStudentObject = new Student("1234", "Maria", "Smith", 97, 75, 87, "CS"); Console.WriteLine("\n\nLast Student"); Console.WriteLine("Student Name: " + aStudentObject.StudentFirstName + " " + aStudentObject.StudentLastName + "\nStudent Number: " + aStudentObject.StudentNumber + "\nMajor: " + aStudentObject.Major + "\nExam Score 1: " + aStudentObject.Score1 + "\nExam Score 2: " + aStudentObject.Score2 + "\nExam Score 3: " + aStudentObject.Score3 + "\nExam Average: " + aStudentObject.CalculateAverage().ToString("F1")); Console.ReadKey(); }
static void Main(string[] args) { //Student testStudentObject = new Student() Student firstStudentObject = new Student(); firstStudentObject.StudentFirstName = AskForStudentName("First"); firstStudentObject.StudentLastName = AskForStudentName("Last"); firstStudentObject.StudentNumber = AskForStudentNumber(); firstStudentObject.Major = AskForMajor(firstStudentObject.StudentFirstName); firstStudentObject.Score1 = AskForExamScore(1); firstStudentObject.Score2 = AskForExamScore(2); firstStudentObject.Score3 = AskForExamScore(3); Console.Clear(); Console.WriteLine("First Student"); Console.WriteLine((firstStudentObject.ToString())); Student secondStudentObject = new Student("1138"); secondStudentObject.Score1 = 99; secondStudentObject.Score2 = 88; secondStudentObject.Score3 = 97; Console.WriteLine("\n\nSecond Student"); Console.WriteLine("Student Number: " + secondStudentObject.StudentNumber + "\nAverage: {0:F1}", secondStudentObject.CalculateAverage()); Student thirdStudentObject = new Student("0451", "Randy", "Bozo"); thirdStudentObject.Major = "Physics"; thirdStudentObject.Score1 = 90; thirdStudentObject.Score2 = 60; thirdStudentObject.Score3 = 50; Console.WriteLine("\n\nThird Student"); Console.WriteLine(thirdStudentObject); Student aStudentObject = new Student("1234", "Test-O", "McTest", 44, 93, 89, "CS"); Console.WriteLine("\n\nLast Student"); Console.WriteLine("Student Name: " + aStudentObject.StudentFirstName + " " + aStudentObject.StudentLastName + "\nStudent Number: " + aStudentObject.StudentNumber + "\nMajor: " + aStudentObject.Major + "\nExam Score 1: " + aStudentObject.Score1 + "\nExam Score 2: " + aStudentObject.Score2 + "\nExam Score 3: " + aStudentObject.Score3 + "\nExam Average: " + aStudentObject.CalculateAverage().ToString("F1")); Console.WriteLine("first student name {0}", firstStudentObject.StudentFirstName); Console.ReadKey(); }//end main
static void Main() { // Create a student object, populating its StudentFirstName, StudentLastName, and StudentNumber properties from static prompt methods of StudentApp class. Student firstStudentObject = new Student { StudentFirstName = AskForStudentName("First"), StudentLastName = AskForStudentName("Last"), StudentNumber = AskForStudentNumber() }; firstStudentObject.Major = AskForMajor(firstStudentObject.StudentFirstName); firstStudentObject.Score1 = AskForExamScore(1); firstStudentObject.Score2 = AskForExamScore(2); firstStudentObject.Score3 = AskForExamScore(3); // Working with added property. while (true) { WriteLine("Enter your expected date of graduation"); string graduationDateString = ReadLine(); if (DateTime.TryParse(graduationDateString, out DateTime graduationDate)) { firstStudentObject.GraduationDate = graduationDate; break; } else { WriteLine("You must enter a valid month, day, and year. Try again"); } } // Clear the screen Clear(); // Using the override of the ToString() method, write a student's information. WriteLine("First Student"); WriteLine(firstStudentObject.ToString()); // Create a second student object using one-argument constructor. Student secondStudentObject = new Student("2345") { Score1 = 95, Score2 = 62, Score3 = 87 }; // Use the Console.WriteLine method, concatenation, and the second student's ID number and average to one decimal point into a string displayed on the console." WriteLine("\n\nSecond Student"); WriteLine("Student Number: " + secondStudentObject.StudentNumber + "\nAverage: {0:F1}", secondStudentObject.CalculateAverage()); // Create a third object using three-argument constructor. Student thirdStudentObject = new Student("5432", "Randolph", "Wonder") { Major = "Math", Score1 = 95, Score2 = 87, Score3 = 72 }; WriteLine("\n\nThird Student"); WriteLine(thirdStudentObject); // Create an object using a seven-argument constructor, then write each of its properties to the console using string concatenation. Student aStudentObject = new Student("1234", "Maria", "Smith", 97, 75, 87, "CS"); WriteLine("\n\nLast Student"); WriteLine("Student Name: " + aStudentObject.StudentFirstName + " " + aStudentObject.StudentLastName + "\nStudent Number: " + aStudentObject.StudentNumber + "\nMajor: " + aStudentObject.Major + "\nExam Score 1: " + aStudentObject.Score1 + "\nExam Score 2: " + aStudentObject.Score2 + "\nExam Score 3: " + aStudentObject.Score3 + "\nExam Average: " + aStudentObject.CalculateAverage().ToString("F1")); ReadKey(); }