Module 2 - Game Skills 3
Assignment 2.08


Objectives: After studying the Module 2 Game Skills 2, you will be able to:

  1. Identify the print zones on the computer screen.
  2. Explain the meaning of output format.
  3. Use print zones to print columns of data in a table format.

YOUR LESSON

Introduction

In the previous assignment, you used two "sets" of variables in order to process the payroll information for Mr. Blue and Mrs. Greene. The use of variables in this way makes it possible to handle sets of data. In Basic 2, you will learn how to use variables more efficiently to handle very large sets of data.

While the Wage Calculator II program works and prints out the output we wanted, it is not very well organized. Format refers to the way information is presented on the screen or in a printed document. If we had a long list of employees, this output format for the wages2.bas program would not clearly show the information. Have you ever seen a printout or screen formatted to display data lined up neatly in columns? That is very easy to do with print zones; so next, we will modify the output format of the program.


Get in the "Zone"

Programmers devote a lot of attention to creating clear output formats. Computer programs often print data in neat columns. In QBasic, this is accomplished with print zones, which are pre-set columns on the screen. Try typing this tiny program to see the print zones on your computer. Can you predict how many print zones there will be?

CLS
PRINT 1,2,3,4,5,6,7,8,9,10
END

Surprise! There should have been only 5 print zones. You should see two rows and five columns of numbers. The comma separating a list of numbers or variables tells QBasicB to print the output in preset print zones. Can you determine how many spaces are in each print zone? These preset print zones give programmers a way to quickly and easily format columns of data.

Try the following program to see some more possibilities. Notice that the assignment statements do not use LET. The use of LET is entirely optional in QBasic. You can use it or not, it's your choice. Also notice that keywords are shown in orange and variable names are shown in green.

CLS
A=1
B=2
C=3
word1$="Go"
word2$="Canes"
PRINT A,B,C
PRINT ,,,word1$,word2$
PRINT ,,word1$
END

Print zones make printing information in columns very easy. You will soon discover that the comma is a very important punctuation mark in QBasic, so be careful how you use them.

The example in the last assignment to calculate wages worked fine, but the output was not easy to read. Can you picture a way to put the data into a table with preset columns using print zones? It would also look nice to have a title up above the table and headings above each column. Reload the wages2.bas program and make the following modifications to the output section. (You will only be making changes to one part of the wages2.bas program, leave the rest of it the way it is). Can you predict the output?

REM Output Results
CLS

PRINT ,"Wage Calculation Display"
PRINT
PRINT
"Name","Rate","Hours","Wage"
PRINT
name1$,rate1,hours1,wage1
PRINT
name2$,rate2,hours2,wage2

Did the output look the way you predicted? Print zones are useful, but you may not always want to use the preset columns. Shortly, you will learn some very powerful techniques for formatting the appearance of data on the screen.


YOUR ASSIGNMENT

In this assignment, you are going to modify the output format of the program you wrote for the last assignment about the area and perimeter of a football field. Here are the details of what to do:

  1. The data should appear in a table format.
  2. The following title should appear above the table: Sports Field/Court Size Comparisons
  3. Include the following column headings: Sport, Length, Width, Perimeter, Area.
  4. Print the data in the appropriate column. All data should be stored in variables for printing...including the name of the sport.
  5. Add information for three more sports of your choice. Some options include a Canadian football field, a soccer field, a tennis court, or a handball court (but not a "food court" or a traffic court). You can look up this information on the Web or in an encyclopedia.
  6. Use color to make the output look appealing.

Save your program as boxes2.bas because you may need it again in the future. No flowchart is required for this program because it would not be too much different from the one you did previously. When you have completed the program, print it and put it in your notebook. Turn this program in as an attachment to Assignment 02.08 - Game Skills 3, but do not zip the file.


Grading Rubric

All assignments will be graded according to a rubric. For Assignment 02.08 - Game Skills 3, the rubric will be as follows:

Required statements used: 4 out of 4 points
Required material included: 2 out of 2 points
Program ran properly: 2 out of 2 points
Proper output: 2 out of 2 points

This assignment is worth a total of 10 points. If you are dissatisfied with your grade, you may redo and resubmit the assignment.


A QBasic Review

Before moving on to the next assignment, be sure that you can do the following:

  1. Identify the print zones on the computer screen.
  2. Explain the meaning of output format.
  3. Use print zones to print columns of data in a table format.

Clearly formatting output data is extremely important when writing computer programs. Print zones are one way of making neatly aligned tables of data.


 Attach the program you wrote for this section to Assignment 02.08 Game Skill 3 in the Dropbox area. Once you have completed the assignment, please move on to the next assignment.

nextnext