CSCI 2000B

Spring 1999

Lab 3



This in-lab assignment includes running and changing three QBASIC programs to prepare you for the out-of-class assignment for the week.

Starting QBASIC:

1. Boot the system.

2. When Windows 95 is up and functional, go to the Start button, select "Programs", then "Departmental Programs", followed by "Math & Computer Science", and "DOS Programs for Math & Computer Science".

3. Hit the "6" key and press the ENTER key.

4. Click on the OK button when it asks for Parameters.

4. Press the ESC key when the first message comes up.

Quitting QBASIC:

1. Under FILE, select EXIT.

2. Type "exit" at the H: prompt and press the ENTER key. You should return to Windows 95. You may need to close the output window from your runs of programs by clicking on the little X button in the very upper right-hand corner.



Program 1:

a) Load in the first program by

i) Go to the FILE menu and select OPEN.

ii) When the OPEN window comes up, double click on the ".." spot under DIR/DRIVES to move up one level in the directory structure.

iii) Double click on the subdirectory CSCI2000.MEP. You may have to use the scroll bar on the side of the DIR/DRIVES list to get it to appear.

iv) Double click on the file LAB3PT1.BAS

b) Read over the program. It sets a variable called NUM1 to have a value of 9, then it does a calculation on NUM1 to get a value into NUM2. Both numbers will then be displayed on the screen.

c) Run the program by going to the RUN menu and select START. On the attached answer sheet write down what you see.

d) Change the value NUM1 is assigned from 9 to 10 (ten) and rerun the program. Write down the result.

i) Move the cursor to the line with "LET NUM1 = 9" using the arrow keys or clicking on the line.

ii) Move to the "9" and delete it. Type in 10

e) Edit the line with the assignment of a value to NUM2 to be the expression

4*NUM1-(7-3^2)

f) Rerun the program and write the result on the answer sheet.



Program 2:

a) Load in the program LAB3PT2.BAS using the same method as for program 1. At the end you will get a question "Loaded file is not saved. Save it now?". Click on "No".

b) Read over the program. It displays the square root and the result of the function INT of a number that is typed in by the user.

c) Run the program and type in the number 25.0 Write down the answers.

d) Rerun and write the answers for the number 6.25

e) Do the same for 9.99

f) Modify the program to calculate INT(real1+2.5) to generate a value for "intreal"

g) Run the program and write down the results for the number 9.99

h) Change the function INT to CINT in the calculation of "intreal".

i) Change the title on the output from "INT" to "CINT"

j) Run the program for the number 8.50 and write down the result.



Program 3:

a) Load in the program LAB3PT3.BAS using the same method as for program 2.

b) Read over the program. It takes the left two characters out of a string using the LEFT$ function and displays both.

c) Run the program and write down the result.

d) Change the program to use the RIGHT$ function to get the rightmost four characters and rerun. Be sure to write the result on the answer sheet.

e) Change the program to get three characters out of the middle of the string starting at the second character by using the function call MID$(string1$,2,4).

f) Run the program and record the answer.

g) Modify the program to have the user INPUT a value into string1$. Run and test.

h) Assign the concatenation of the result of the MID$ function with string1$ into a new variable called string3$

i) Output the values of string1$, string2$ and string3$.

j) Run the program and record the result. You can enter any string you want.

k) Print out your version of the program by going to the FILE menu and selecting PRINT. Click on OK and it should print.

l) Attach the print out of the program to the Answer Sheet and turn them in when done.

Lab 3

Answer Sheet

Name: __________________________________________



Program 1:

Output from step c) _________________________________________________________

Output from step d) _________________________________________________________

Output from step f) _________________________________________________________





Program 2:

Output from step c) _________________________________________________________

Output from step d) _________________________________________________________

Output from step e) _________________________________________________________

Output from step g) _________________________________________________________

Output from step j) _________________________________________________________





Program 3:

Output from step c) _________________________________________________________

Output from step d) _________________________________________________________

Output from step f) _________________________________________________________

Output from step j) _________________________________________________________

Don't forget to print out the program, attach it to this sheet, and turn it in before you leave.