Custom Search
 
  
 

Programming Intro

Chapter 7 Questions

Introduction to Programming

 
CHAPTER 7

EXERCISE SOLUTIONS

The following flowcharts and programs present possible solutions to the exercises.

1. Stock Purchase Flowchart and Program

2. Election Results Flowchart and Program

You may have noticed that the data field for candidate number contains a 1, 2, 3, 4, and that this code could be used as a subscript to reference the correct locations in the arrays. To modify the program to take advantage of this, you could replace statements 90 through 220 with the following statements:

90     LET K(X) = K(X) + V

100    LET N1$(X) = N$

110     GOTO 70

When the value of candidate number is 1, the number of votes cast for candidate 1 would be added to K(l); when its 2, the number of votes cast for candidate 2 would be added to K(2); and so on.

When you are defining data and data codes, it is a good idea to think about how you are going to use the data in the programs. You maybe able to save yourself coding time.

Figure 7-2.Parts inventory flowchart and program.

Figure 7-2 contd.Parts inventory flowchart and program.







Western Governors University
 


Privacy Statement - Copyright Information. - Contact Us

Integrated Publishing, Inc. - A (SDVOSB) Service Disabled Veteran Owned Small Business