10.2 Lab

Overview

10.2 Lab

10.2 Scratchpad Chars and Strings

Work through the stories in order. Use the acceptance criteria to check each feature, and complete the nested tasks using the specified names, values, and scenarios.

Inspect character and numeric conversions
Acceptance Criteria
Acceptance criteria
  • The requested char, int, and string variables contain 7, 8, and "7" in their respective types.
  • The numeric value of the digit character and the string concatenation are inspected as directed.
  • The character codes for A and X are observed as 65 and 88; converting integer 84 to char produces T.
Instructions
1.Download the start file.

10.2 Lab Start.zip

10.2 Lab Start.zip
A Download the start file.
2.Create Variables within the Static Main method

Make sure to add comments after every variable with the proper binary formatting.

A Create a variable of type Char. Set it equal to 7.
B Create a variable of type int. Set it equal to 8;
C Create a variable of type string. Set it "7";
D Create a second variable of type string. Set it equal to the Char variable.
E Create a variable of type double. Set it equal to the numeric value of the Char variable.
F Create a third variable of type string. Set it equal to the concatenation of the first two string variables.
3.Checking Unicode Values for type Char
A Set the create Char variable to A.
B Create another variable of type Char. Set it equal to X.
C Build the Solution: Set a break point at the end of the Static Main method. Add the the two Char variables to the Watch.

The value of the first Char variable should be 65, while the value of the second Char variable should be 88

D Create another variable of type int. Set this variable to 84.
E Build the Solution: Set a break point at the end of the Static Main method. Add the variable created in the “Create another variable of type int. Set this variable to 84” task to the Watch Window.

Make sure to Cast the variable to type Char, when adding to the Watch window.

Build and modify a string with StringBuilder
Acceptance Criteria
Acceptance criteria
  • The StringBuilder is initialized with capacity 32 and receives the required repeated A characters.
  • The AppendFormat, Replace, Remove, and ToString chain is carried out with the specified arguments.
  • Debugger observations distinguish the number of characters from the allocated capacity.
Instructions
4.Using StringBuilder
A Create a variable of type StringBuilder, passing in 32 when instantiating the StringBuilder

Remember StringBuilder stores in increments of 16 bytes.

B Using a for loop, append the letter A to the StringBuilder.
C Add the following line of code after the for loop.
String s = stringBuilder.AppendFormat("{0} {1}", "Jeffrey", "Richter").Replace(' ', '-').Remove(4, 3).ToString();
D Write to the Console, the variable s.
E Build the Solution: Ensure that the variable s, is displayed to the console window.
Completion review
5.Review the feature acceptance criteria
A Confirm the required results

Return to each story and verify its acceptance criteria. Preserve the submission format and destination stated in the activity; a reading, setup guide, lab, video demonstration, and oral final may require different evidence.

Inspect character and numeric conversions Build and modify a string with StringBuilder
Task reference links

Use these links to revisit the named tasks referenced in the directions.

Create another variable of type int. Set this variable to 84