Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Interpolated Strings Optional and Named Arguments Encoding HTML 1.Create a class

ID: 3875563 • Letter: I

Question

Interpolated Strings

Optional and Named Arguments

Encoding HTML

1.Create a class called Student.

2.Create auto-implemented properties for the first name, last name, and state of residence. Auto-generated properties don’t have a body.

public int

Quantity { get; set; };

3.Create a constructor method for the class that takes 3 parameters: 1 for each property: first name, last name, and state of residence, IN THAT ORDER. For the state of residence parameter, provide a default value of “SC” if the programmer doesn’t supply a value for the state of residence parameter. Assign these 3 parameter values to the corresponding properties in the body of the constructor.

4.Create a method called StudentInfo that returns a string message similar to the following, but with the name of the student currently stored in the class: SC-Ben Harper

For the output, use an interpolated string (the variables/properties should be listed in the quoted literal).

5.Create another method called WriteStudentInfoHTML

that outputs an HTML page to a

file called StudentInfo.html with this information as before: SC—Ben Harper

However, the SC should be bold, the hyphen should use an em dash, and the title of the document should be the student’s first and last names. The <b>...</b> tags will make text bold. An em dash is the decimal Unicode value of 8212. The title of an HTML document appears on the tab of the browser window (the title tag in the HTML).

A minimal HTML document should have the following tags (in the correct order and placement):

<!DOCTYPE html>

Html (opening and closing)

head (opening and closing)

meta

title (opening and closing)

body (opening and closing)

Make sure you close the file at the end of the method.

(Continued)

6.Create a final method called WriteStudentInfoTags that will create an html document that shows the tags used in the previous file...an html document with html tags in the body.

·This method should create a new HTML document called StudentInfoTags.html, and a title of the student’s first and last names and the word “Tags”: Ben Harper Tags

·Write out all tags until the opening body tag

·Read the StudentInfo.html file line-by-line from the previous method.

·Encode each line to HTML with the WebUtility.HtmlEncode() method. You will need to use System.Net to use the WebUtility class.

·Write out each encoded line into the StudentInfoTags.html file body tag, and end each line with a <br /> tag, to tell a browser that this this is a new line.

·Close the body tag and any other open tags in the StudentInfoTags.html file. Make sure you close both files when done.

7. Finally, write a program (either console or WinForms) that

Asks the user for a first and last name only

Creates a student object by passing ONLY the last and first names, and IN THAT EXACT ORDER. (Don’t pass a state to the object’s constructor). You will have to use

named arguments to accomplish this.

Calls the StudentInfo method and outputs it to the screen

Calls the WriteStudentInfoHTML method

Calls the WriteStudentInfoTags method

·You should be able to double-click on the 2 html documents, and they should open up in the default browser.

·Verify that StudentInfo.html file shows the state in bold, and the em dash between the state and name.

·Verify that the StudentInfoTags.html file shows the tags from the document.

Sample output from a console program and files follows.

Explanation / Answer

pubic Class Student // 1st Step

{

public string First_Name{ get; private set; } // 2nd step Create auto-implemented properties

public string Last_Name{ get; private set; }

public string State_of_Residence{ get; private set; }

public Student(string First_Name,string Last_Name,string State_of_Residence) // 3rd Step

{

this.First_Name = First_Name;

this.Last_Name = Last_Name;

this.State_of_Residence = State_of_Residence

}

public string First_Name

{

get { return this.First_Name; }

set { this.First_Name = First_Name; }

}

public string Last_Name

{

get { return this.Last_Name; }

set { this.Last_Name = Last_Name; }

}

public string State_of_Residence

{

get { return this.State_of_Residence; }

set { this.State_of_Residence = State_of_Residence; }

}

public string StudentInfo(string First_Name, string Last_Name) // 4th step

{

return "First_Nme + Last_Name" ;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote