Question: C# practice Create a new Console Application project (C#, .NET Core) called Question01 (without quotes). In your Program class, create a new method called GetInfo.

C# practice

Create a new Console Application project (C#, .NET Core) called "Question01" (without quotes).

In your Program class, create a new method called GetInfo. This method receives one parameter: A string that is expected to contain a sentence. It returns a string that contains a metadata report on the specified string. The report should include: the total number of characters (Hint: spaces are characters), the total number of words, and the longest word in that string. Each one of these should appear in an individual line in the report.

Once you are done, write the test harness in the Main method of your Program class, ensuring your code is fully functional as per requirements. In other words, define two or three random sentences in your Main method, and display a sentence report in the Console for each one of them. You can choose your sentences freely.

For full marks, ensure your method handles exceptions properly, and in case of errors, display clean and meaninful messages to the user (Hint: Implement try-catch blocks).

Question 1 options:

Hide hint for Question 1

Make sure you completely adhere to all requirements. Do not change anything in terms of behavior, property names, method names, identifiers, etc. You are expected to follow all C# naming conventions. Penalties apply if these guidelines are not followed. COPY THE ENTIRE CONTENT OF YOUR PROGRAM.CS FILE AND PASTE IT IN THE ANSWER BOX FOR THIS QUESTION. Incomplete code will be graded ZERO marks.

Create a new Console Application project (C#, .NET Core) called "Question02" (without quotes).

In your Program.cs file, inside your Question02 namespace and outside the Program class, create a new class called Person. In this class, you must define at least 5 properties that describe attributes that a person has. You are free to come up with your own properties, but you must use at least one instance of each of the following data types: string, int, DateTime, boolean, and an enumerator of your making.

In your Person class, override the ToString method, so that it returns a string that contains meaningful information on the object.

Once you are done, write the test harness in the Main method of your Program class, ensuring your code is fully functional as per requirements. In other words, define two or three random Person objects in your Main method, and display their information in the Console. You can create your people freely.

For full marks, ensure at least one of your properties are automatically calculated.

Hide hint for Question 2

Make sure you completely adhere to all requirements. Do not change anything in terms of behavior, property names, method names, identifiers, etc. You are expected to follow all C# naming conventions. Penalties apply if these guidelines are not followed. COPY THE ENTIRE CONTENT OF YOUR PROGRAM.CS FILE AND PASTE IT IN THE ANSWER BOX FOR THIS QUESTION. Incomplete code will be graded ZERO marks.

Create a new Console Application project (C#, .NET Core) called "Question03" (without quotes).

In your Program.cs file, inside your Question03 namespace and outside the Program class, create a new static class called TextService. In this class, implement two static methods: SaveText and LoadText.

The first method, SaveText, is intended to write a specified text to the hard drive as a text file (.txt), in a specified location. It takes two parameters: A string containing the text to be saved, and a string that defines the full physical path of the file that will be created (i.e. C:\MyFolder\Example.txt). Make sure your method handles line breaks properly.

The second method, LoadText, is intended to read and return all text from a specified text file. It should take only one parameter: A string containing the full physical path to the file that will be loaded (i.e. C:\MyFolder\Example.txt). Note that you may need to read multiple lines.

Once you are done, write the test harness in the Main method of your Program class, ensuring both methods are fully demonstrated. In other words, call the first method to write a file to your hard drive, and afterwards, call the second method to read the very file you have just created (do include a Console.WriteLine at the end to display the text you have just loaded). Your code must be tested with a text where the number of lines is determined by the last digit of your student number. For example, if the last digit of your student number is 1, your text should have 1 line. If the last digit of your student number is 2, your text should have 2 lines. If the last digit of your student number is 0, your text should have 10 lines. The content of this text can be creatively defined by you. You can choose anything, from movie names, to your favorite songs, or famous quotes.

Hide hint for Question 3

Make sure you completely adhere to all requirements. Do not change anything in terms of behavior, property names, method names, identifiers, etc. You are expected to follow all C# naming conventions. Penalties apply if these guidelines are not followed. COPY THE ENTIRE CONTENT OF YOUR PROGRAM.CS FILE AND PASTE IT IN THE ANSWER BOX FOR THIS QUESTION. Incomplete code will be graded ZERO marks.

Create a new Console Application project (C#, .NET Core) called "Question04" (without quotes).

In your Program.cs file, inside your Question04 namespace and outside the Program class, create a new class called Person. In this class, you must define at least 5 properties that describe attributes that a person has. You are free to come up with your own properties, but you must use at least one instance of each of the following data types: string, int, DateTime, boolean, and an enumerator of your making.

In your Person class, override the ToString method, so that it returns a string that contains meaningful information on the object.

In addition, the Person class should define two static methods: SaveData and LoadData.

The first method, SaveData, is intended to serialize a specified Person object to the hard drive as an XML file (.xml), in a specified location. It takes two parameters: A Person object to be saved, and a string that defines the full physical path of the directory in which the output XML file will be created (i.e. C:\MyFolder\).

The second method, LoadData, is intended to deserialize and return a Person object from a specified XML file. It should take only one parameter: A string containing the full physical path to the file that will be loaded (i.e. C:\MyFolder\Person_e4v6g-qw3v46-w34ev6-ew45brt.xml).

Once you are done, write the test harness in the Main method of your Program class, ensuring your code is fully functional as per requirements. In other words, define a random Person object in your Main method, serialize it to your hard drive, and then deserialize it, displaying the loaded object in the Console.

For full marks, ensure possible exceptions are properly treated in your code, and in case of errors, a clean and meaningful message is displayed to the user (Hint: Implement try-catch blocks).

Make sure you completely adhere to all requirements. Do not change anything in terms of behavior, property names, method names, identifiers, etc. You are expected to follow all C# naming conventions. Penalties apply if these guidelines are not followed. COPY THE ENTIRE CONTENT OF YOUR PROGRAM.CS FILE AND PASTE IT IN THE ANSWER BOX FOR THIS QUESTION. Incomplete code will be graded ZERO marks.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!