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"

            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 in the Properties Window BEFORE writing code! Form(1) Solution Explorer: Name: frmArithmetic.cs (right click file name in solution explorer and RENAME) Designer: Text : your name ARITHMETIC Button(6): Designer: Name(s): btnAdd, btnSubtract, btnMultiply, btnMax, btnRandom, btnClear BackColor: your choice (make readable) Text: Add, Subtract, Multiply, Bigger, Random #s, Clear All TextBox(2) for Input: Designer: Name: txtIn1, txtIn2 ListBox(1) for Output: Designer: Name: lstOut Text: blank Font: Consolas, 9 point BackColor: your choice ForeColor: make readable PictureBox(1) for Decoration: Designer: Name: picMath Image: - you choose - jpg or png SizeMode: Zoom
YOUR CODE SHOULD: 1. btnAdd_Click(): Read the numbers from the textboxes and store in variables of type "int". Protect by using: try { your input code reading from the textboxes ... } catch(Exception ex) { error message using MessageBox return; } code that adds the two numbers when button is pressed. display the answer as shown. 2. btnSubtract_Click(): Read the numbers from the textboxes and store in variables of type "int". Protect by using: try { your input code reading from the textboxes ... } catch(Exception ex) { error message using MessageBox return; } code that subtracts the two numbers when button is pressed. display the answer as shown. 3. btnMultiply_Click(): Read the numbers from the textboxes and store in variables of type "int". Protect by using: try { your input code reading from the textboxes ... } catch(Exception ex) { error message using MessageBox return; } code that multiplies the two numbers when button is pressed. display the answer as shown. 4. btnMax_Click(): Read the numbers from the textboxes and store in variables of type "int". Protect by using: try { your input code reading from the textboxes ... } catch(Exception ex) { error message using MessageBox return; } code that finds bigger of the two numbers when button is pressed. Use the Math library (Math.Max) display the answer as shown. 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 listbox when 'Clear' is pressed. Put the focus back onto txtIn1. Show the picture. 7. picMath_Click(): Make the picture disapper