cis 202: ARITHMETIC

ARITHMETIC: Add, Multiply, Subtract, Max and Random

1. Come to class as there may be corrections, changes and additions.   Significant late penalty per day.
2. Follow these directions to create a C# Windows program.  
3. Follow these directions to SUBMIT a zipped folder called "ARITHMETIC"
4. Grading Sheet.

            hello pic             hello pic


            hello pic             hello pic


            hello pic             hello pic

    ** Challenge: One new button widens/shrinks form by 200 pixels revealing a picture moving down the form and circling back to the top. **
    HINT: timer causes picture to move down the page. check position to know when to move it back up top



ADD THE FOLLOWING CONTROLS SIMILAR TO THE PICTURE ABOVE. CHANGE THE FOLLOWING PROPERTIES: * Change Name property of ALL controls BEFORE writing codein the Properties Window! * Properties changed IN code should be changed in the form_Load method (double click on the form) Form(1) Solution Explorer: Name: frmArithmetic.cs (right click file name in solution explorer) Change In Code: Text : your name Designer: AcceptButton(Enter): Add CancelButton(ESC): Clear Button(6): Designer: Name(s): btnAdd, btnSubtract, btnMultiply, btnMax, btnRandom, btnClear BackColor: your choice (make readable) Change In Code: Text: Add, Subtract, Multiply, Bigger, Random Fill, Clear All TextBox(2): Designer: Name: txtIn1, txtIn2 TextAlign: Center Label(1) for Output: Designer: Name: lblOut Text: blank BackColor: your choice BorderStyle: FixedSingle AutoSize: False (allows you to resize the label and make bigger) TextAlign: MiddleCenter PictureBox(1) for Decoration: Designer: Name: picMath Image: - you choose a math-related image SizeMode: Zoom
YOUR CODE SHOULD: 1. btnAdd_Click(): Read the numbers from the textboxes and store in variables of type "int". Add the two numbers when 'Add' is pressed. Display the answer in the label as shown. Make this the "AcceptButton" (ENTER) by changing the FORM PROPERTY and selecting this button. Protect by using: try { your code.... } catch(Exception ex) { error message using MessageBox } 2. btnSubtract_Click(): Read the numbers from the textboxes and store in variables of type "int". Subtract the two numbers when 'Subtract' is pressed. Display the answer in the label as shown. Protect by using: try { your code.... } catch(Exception ex) { error message using MessageBox } 3. btnMultiply_Click(): Read the numbers from the textboxes and store in variables of type "int". Multiply the two numbers when 'Multiply' is pressed. Display the answer in the label as shown. Protect by using: try { your code.... } catch(Exception ex) { error message using MessageBox } 4. btnMax_Click(): Read the numbers from the textboxes and store in variables of type "int". Use the Math library (Math.Max) to determine the bigger number. Display the answer in the label as shown. Protect by using: try { your code.... } catch(Exception ex) { error message using MessageBox } 5. btnRandom_Click(): Create ONE random number object using the Random class. Random() rnd = new Random(); Generate two random numbers between 1 - 100. int num = rnd.Next(1,101); Put a random number into each textBox. 6. btnClear_Click(): Clear the two numbers in the textBoxes and the answer in the label when 'Clear' is pressed. Put the focus back onto txtIn1. Make this the "CancelButton" (ESC) by changing the FORM PROPERTY and selecting this button. 7. picMath_Click(): Make the picture disapper Form Properties: AcceptButton(ENTER), CancelButton(ESC) Change properties in code form load after Initialize_Component() btnAdd.Text = ...