Module 4 - Preparation
Assignment 4.04
Practice Time


First, print this page. Then, reload your wages2.bas program and run it to refresh your memory about how it works and what output is produced.

Next, we are going to modify the program to use READ and DATA instead of LET statements. The modified flowchart is shown below. Study it carefully.

This flowchart is very detailed.

Notice that the flowchart symbol for READ is a parallelogram. Other than that minor change, the flowchart looks pretty straightforward.

But wait! Are you curious about why there is no flowchart symbol for DATA and why data are not included in a flowchart? There is a least one very simple reason.

Let's face it, even though flowcharts are helpful for visualizing an algorithm, they can be a real pain to create and modify. If you had a program that required a lot of information, including a DATA statement for every single set of data, the flowchart could get pretty big! In theory, if the program works for one set of data, it will work for any amount of data. Besides, data often change. It would be a waste of time to keep modifying a flowchart every time the data changes.

Later, you will also learn to use loops and another type of variable to avoid having one READ statement for every DATA statement.


The program corresponding the modified flowchart is shown to the right. Study it carefully and see if you can predict the output.

Make the modifications shown and run the program to test your prediction.

REM Wage Calculator III - Final Chapter
REM Pablo Programmer
REM 01/02/01
'
REM Read in the data
READ
name1$,rate1,hours1
READ name2$,rate2,hours2
'
REM Calculate Wages
LET
wage1=hours1*rate1
LET
wage2=hours2*rate2
'
REM Output Results
CLS

PRINT
"Wage Calculation Display"
PRINT
"The wage for "; name1$ ;" is $"; wage1 ;"."
PRINT
"The wage for "; name2$ ;" is $"; wage2 ;"."
'
REM The list of data
DATA
Mr. Blue,5.25,23.0
DATA
Mrs. Greene,6.00,34.25
END

Check Your Prediction

There was a difference in the "output" between the program written with LET statements and the modified program written with READ-DATA statements.

True
False

Was your prediction correct? There should not have been any difference between the two programs. Why? Because all you did was substitute READ and DATA for the LET statements. In effect, you just changed the way the information gets stored in the variables, the calculations and the output stayed the same.

Using READ and DATA is beneficial because it is a much more efficient way of entering sets of data than simply using many separate LET statements. Programmers like efficiency!

Also, please notice that the flowchart is taking on much greater detail, especially with regard to the PRINT statements. Your flowcharts should begin to take on more detail as well.


After you have modified the program, return to the previous page.

 

previousnext