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
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 dont 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 doesnt 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: SCBen Harper
However, the SC should be bold, the hyphen should use an em dash, and the title of the document should be the students first and last names. The ... 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):
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 students 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
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. (Dont pass a state to the objects 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started