


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for creating a new project in visual studio 2008 named 'testarith' to test how arithmetic operators work on integers, singles, and strings. The steps to create three sections on the form, each with a compute button, textboxes for input, and a clear button. The document also includes instructions for testing input errors and various arithmetic and string operators.
Typology: Lab Reports
1 / 4
This page cannot be seen from the preview
Don't miss anything!



1. Testing Arithmetic and String Operators
For this application, you should open Visual Studio 2008 and create a new project named something like TestArith. Refer back to the instructions from previous labs for how to do this. This new project should be in the same lab projects folder that you created on your H: drive last time.
In the initial form , change the Text property of the form for the new Test Arithmetic project so that the form box has a nice header label.
This application will have three sections on the form. The first section will be used to test how the arithmetic operators work on Integers, the second section will test how the arithmetic operators work on Singles, and the third section will work with Strings.
Each of the three sections should look something like the following sketch and as demonstrated in class:
First |___________________| | Compute | (button) Second |___________________| | Integers |
Result |___________________| | Clear | (button)
This one section of the program has three Labels, three TextBoxes, and two Buttons. These objects can be copied and pasted to the two sections below it for testing the other types.
Section 1: Testing Integers
For the Compute Integers button, write the program that Declares three variables named first, second, and result as type Integer Get values for first and second from TextBox1 and TextBox2. Add the two numbers and assign it to the variable result. Put the result value into TextBox3.
For the Clear button, write the program that Assigns the empty string “” to all three textboxes
Test for Input Errors:
Start with the operator +, as demonstrated in class. Now run the program and click the Compute Integer button without typing any number. What happens?
Now run the program again, and instead of typing a valid Integer, type a Single – for example, type 1.6 in the first TextBox. What happens?
What happens if you type Hello in the first TextBox?
*Test the Integer Operators +, -, , /, %: For the remaining tests, put the operator into the program line that computes with the first and second number and assigns it to result. Then run the program with two different sets of numbers and write your results on this paper. For each operator, in the first set of numbers, the first number should be bigger than the second, but in the second set of numbers, the first number should be smaller than the second. Negative numbers can be used. The first two sets of numbers are filled in for you – you can pick the remaining ones to test.
Integer Operator First Integer Second Integer Result
Extra: What happens if you use / on Integers such as 11 / 3?
Section 3: Testing Strings
Make a third section by copying all the Labels, TextBoxes and Buttons as before. Change the label of the first button to Compute Strings. Observe the names of the TextBoxes and Buttons.
Write programs for the two buttons as before, changing the types of the variables to String and the names of the TextBoxes as necessary. Change the String operator to &.
Test for Normal Input:
Run the program, typing in two Strings and write down the result:
String Operator First String Second String Result &
Test for Input Errors:
Run the program again with the & operator and click the Compute String button without typing any strings in the boxes. What happens?
Now run the program again, and instead of typing character Strings, type numbers, either Integer or Single in the TextBoxes. What happens?
When you have completed your testing, wait for the discussion at the end of class. Save this lab paper to hand in with Wednesday’s lab.