CISY 125 – In-Class Lab 2

 

In today’s lab we will take a brief look at Q-Basic.

 

QBasic

For more detailed notes on starting and using QBasic see the QBasic Overview in the QBasic Lectures section of the Instructor Notes.  NOTE:  Please don’t print this out in lab today…they are large due to the pictures.

 

To start QuickBasic, double-click on the icon that is on the computer desktop.

 

Press ESC to dismiss the Welcome box.

 

In the window labeled Untitled enter in the sample program from below.  As you enter in the program, you do NOT have to type the QBasic commands in upper case (REM, CLS, INPUT, LET, PRINT, END).  After you type a line and press enter, the computer will change the case of the commands to upper case.

 

It is extremely important that you always save a program before you run it for the first time.  The worst case scenario of a bug in a program is that QBasic will close and ALL of your work is lost.

 

From the menu select File then Save.

 

In the Save dialog, the line under the File Name is where QBasic is attempting to save the file.  In the labs it will default to C:\WINDOWS\SYSTEM.  However, you do not have access to this directory and if you attempt to save to this directory you will get a PATH/ACCESS error.  You must save either to a floppy (A:) or to the ROOT of the C: drive. 

 

To get to the root of the C: drive keep double clicking on [..] until the line under filename reads C:\

 

In the filename field, please only enter 8 characters.  Only uses letters and numbers.  No spaces.  Here, enter ICELAND then press enter.

 

If you get an error message, call over the instructor.

 

To run the program select Run then Start.

 

Enter in the numbers as seen below in the Sample Run.

 

Submitting the program

 

1.      Submit the QBasic code electronically (either hand in the In-Class Floppy, or e-mail the QBasic code)

 

AND

 

2.      Submit the QBasic code on paper. 

 

 

SAMPLE PROGRAM

REM please put your name here

CLS

INPUT "Enter total population of Iceland"; TotalPopulation

INPUT "Enter total square miles of Iceland"; TotalSqMiles

LET PeoplePerSqMile = TotalPopulation / TotalSqMiles

PRINT "People per square mile in Iceland is  "; PeoplePerSqMile

END

 

SAMPLE RUN

Enter total population of Iceland? 242000

Enter total square miles of Iceland? 39800

People per square mile in Iceland is   6.080402

 

 

Press any key to continue