202 test 1
Test information may change! Come to class to stay on top of details. READ the NOTES that are online and READ the assigned readings!
Test may NOT be "made up" without prior arrangements or VERIFIED EMERGENCY!
Make-up tests will be different, will be given the following morning at 6:30am and require a medical excuse.

Make a CAP!
This guide is not a "promise" of what will be on the test, but is simply an outline of topics that MAY be on the test that I provide to be helpful to you. Other topics not listed may also sneak onto a test from time to time.

Understand that a test is a SAMPLING and can not possibly cover all information from class. The idea, however, is that you must study all the information since you don't know for certain what questions will show up. This is for your benefit as it motivates you to learn more!

programs based on an algorithm written in a computer language such as C# transform data into information beginning programming in C#: programming environment: C#, visual studio, windows creating projects BIG 5: toolbox, properties, solution explorer, code editor, designer .NET class library provides code that can be used compile, execution IL, CLR, JIT windows programs class, object, instantiate properties methods events MessageBox class Show() method all output must be: 1. a string: string s = "Hello!"; MessageBox.Show( s ); 2. a number IMplicitly converted to a string: int x = 99; MessageBox.Show( x + " " ); 3. a number EXplicitly converted to a string: ( ToString() ) int x = 99; MessageBox.Show( x.ToString() ); windows controls control objects have properties ands methods and events: Form (default event - Load) (refer to "this") Button (default event - Click) TextBox Label PictureBox (default event - Click) properties Name Text(hot keys &) TextAlign Visible, Enabled BackColor AutoSize - Label Image, SizeMode - PictureBox AcceptButton (enter), CancelButton (esc) - Form methods Show() Hide() Parse() ToString() Focus() SelectAll() events button_Click() pictureBox_Click() frmMain_Load() variables types: string int double declaring name should be meaningful must declare before using scope - local variables declared WITHIN a method scope is only within that method - class-level variables (fields) declared in the class but outside of any method scope is that they are visible to any method in the class lifetime - local variables declared WITHIN a method lifetime is life of method - class-level variables (fields) declared in the class but outside of any method lifetime is that they hold their value for the life of the program assigning values to variables "=" thought of as "GETS" string string state = "PA"; state = "VA"; int int num = 87; num = -99; int x; x=100; double double weight = 654.321; weight = 8.7; double d; d = -3.145; literals "dog", "boy" 88, 100, -9 99.9, -0.8 constant const int SIZE = 99; const double FACTOR = 1.5; ** conversion between types string to number explicit conversion Parse() number to string implicit lblOut.Text = "Equals = " + x; explicit ToString( ) ("C") ("N2") ("P") number to number explicit casting (narrow) double d = 3.7; int i = (int) d; implicit casting (widen) int i = 99; double x = i;
read across then down FROM FROM FROM double int string ------------------------------------- TO double - * * double.Parse() - TO int - (int) * int.Parse() - TO string - ToString() ToString() * * = no conversion needed
Displaying Numeric Values and Explicit Conversion exceptions run-time errors bad conversion division by zero protection: try { code to protect } catch { error message } strings joining strings with '+' string s1 = "Hello"; string s2 = s1 + " " + "World"; building up strings with '+=' string s1 = "Hello "; s1 += "World"; s1 += "!"; newlines and tabs (\n, \t) (Environment.NewLine) math arithmetic operators (precedence) + - * / % accumulation += -= *= increment and decrement ++ -- Random class create a new random object: Random rnd = new Random(); // constructor creates the object "instantiate", constructor method Button class => btnDoIt object (created through designer) Random class => rnd object ( created with new Random()) readability refactor naming spacing comments explain why header in code syntax vs logic errors vs run-time errors testing / debugging looking for run-time errors looking for logic errors NOT looking for syntax errors

EXAMPLES: The statement, int q = 7 / 2; results in a value of __________ being stored in q. a.) 3.5 b.) 3 c.) 2 d.) 1 The statement, int r = 7 % 2; results in a value of __________ being stored in r. a.) 3.5 b.) 3 c.) 2 d.) 1 The statement, MessageBox.Show( "The answer is " + 7 + 3); shows what? a.) The answer is 10 b.) The answer is 73 c.) Neither - syntax error. d.) Neither - run time error. The statement, MessageBox.Show( "The answer is " + (7 + 3)); shows what? a.) The answer is 10 b.) The answer is 73 c.) Neither - syntax error. d.) Neither - run time error. Declare an int variable called num and initialize it to zero. i. num int == 0; ii. int num = 0; a.) i only b.) ii only c.) both i & ii d.) neither i nor ii Display the greeting "Hello Bill!" in label1 where 'Bill' is entered in textBox1. a.) label1.Text("Hello + textBox1.Text"!"); b.) label1.Text = "Hello " + textBox1.Text + "!"; c.) label1.Text("Hello " + textBox1.Text + "!"); d.) label1.Text = "Hello" + textBox1.Text + "!";
WRITE A SINGLE C# STATEMENT TO... ------------------------------ increase the int variable, X, by 12 change the title of a form to "Math" show the value of the double variable, D, in txtOut as currency say "hello" in a messageBox say "hello" in a messageBox to whatever name is in the textbox, txtIn declare 5 int variables a, b, c, d and e and set them all to zero assign the average of 2 int variables, x and y to double z preserving any fractional result
WRITE CODE ---------- Get a number from a TextBox called txtIn and put it into an int variable called num. Triple the int variable num. Write it to txtOut saying "The number is" followed by num. Generate a random number between 1 and 100 and report its value using a MessageBox Report which of the int variables a or b are the biggest in lblOut Join the strings in txt1 and txt2 and display in txt3. red blue