19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

(e) Print out the names <strong>and</strong> phone numbers contained in the current directory.<br />

(f) Terminate the program.<br />

6. Table 7.6 contains the statistics for a stock portfolio. (The current prices are<br />

given for October 1, 1998.)<br />

TABLE 7.6<br />

Stock Portfolio<br />

Number Date Purchase Current<br />

Stock of Shares Purchased Price/Share Price/Share<br />

Amgen 200 8/19/97 50.750 75.625<br />

Delta Airlines 100 12/3/97 111.750 97.250<br />

Novell 500 8/27/97 10.375 12.250<br />

PPG 100 12/18/97 56.750 54.500<br />

Timken 300 3/13/98 34.625 15.125<br />

(a) Compose a program to create the sequential file STOCKS.TXT containing<br />

the information in Table 7.6.<br />

(b) Compose a program to perform the following tasks. A possible form design<br />

is shown in Figure 7-9.<br />

(1) Display the information in the file STOCKS.TXT as in Table 7.6 when<br />

the user clicks on a “Display Stocks” comm<strong>and</strong> button.<br />

(2) Add an additional stock onto the end of the file STOCKS.TXT when the<br />

user clicks on an “Add Stock” comm<strong>and</strong> button. The data for the new<br />

stock should be read from appropriately labeled text boxes.<br />

(3) Update the Current Price/Share of a stock in the file STOCKS.TXT<br />

when the user clicks on an “Update Price” comm<strong>and</strong> button. The name<br />

of the stock to be updated <strong>and</strong> the new price should be read from the<br />

appropriate text boxes. The file STOCKS.TXT should then be copied to<br />

a temp file until the specified stock is found. The update record for this<br />

stock should then be written to the temp file, followed by all remaining<br />

records in STOCKS.TXT. Finally, the original STOCKS.TXT file<br />

should be erased <strong>and</strong> the temp file renamed to STOCKS.TXT.<br />

(4) Process the data in the file STOCKS.TXT <strong>and</strong> produce the display<br />

shown in Figure 7-10 when a “Show Profit/Loss” comm<strong>and</strong> button is<br />

clicked.<br />

(5) Quit.<br />

FIGURE 7-9 Possible Form Design for <strong>Programming</strong> Project 6<br />

<strong>Programming</strong> Projects 239

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!