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.

318 <strong>Computer</strong> <strong>Programming</strong> <strong>Concepts</strong> <strong>and</strong> <strong>Visual</strong> <strong>Basic</strong><br />

two columns have been filled in, the corresponding average <strong>and</strong> grade should<br />

be recomputed.<br />

3. Tic-Tac-Toe. Write a program that “officiates” a game of tic-tac-toe. That is, the<br />

program should allow two players to alternate entering X’s <strong>and</strong> O’s into a tictac-toe<br />

board until either someone wins or a draw is reached. If one of the players<br />

wins, the program should announce the winner immediately; in case of a<br />

draw, the program should display “Cat’s game”. The players should enter their<br />

plays by clicking on the desired cell in the tic-tac-toe grid, <strong>and</strong> the program<br />

should check that each play is valid. Optional Enhancement: Allow the players<br />

to enter a number n. The program should officiate a best-of-n tournament,<br />

keeping track of the number of games won by each player until one of them<br />

wins more than half of the games. Ignore draws.<br />

4. Hangman. Write a program to play Hangman. (See the following Hangman<br />

form.) A list of 20 words should be placed in a sequential file <strong>and</strong> one selected<br />

at r<strong>and</strong>om with Rnd. The program should do the following:<br />

(a) Draw a gallows on the screen with three line controls.<br />

(b) Create a grid having 1 row <strong>and</strong> 26 columns, <strong>and</strong> fill the grid with the 26 letters<br />

of the alphabet.<br />

(c) Create a second grid of one row <strong>and</strong> the number of columns equal to the<br />

length of the word selected.<br />

(d) Each time the user clicks on one of the letters of the alphabet, that letter<br />

should be removed. If the letter is in the selected word, its location(s) should<br />

be revealed in the second grid. If the letter is not in the word, another piece<br />

of the man should be drawn with a shape control.<br />

5. Inventory Control. Write an inventory program for a book store <strong>and</strong> save the information<br />

in a sequential file. Each record should consist of five fields—title, author,<br />

category, wholesale price, <strong>and</strong> number in stock. (The two categories are fiction <strong>and</strong><br />

nonfiction.) At any time, the program should display the titles of the books in stock<br />

in a list box, for which the user should have the option of displaying either all titles<br />

or just those in one of the two categories. When a book is selected from the list, its<br />

title, author, category, wholesale price, <strong>and</strong> number in stock should be displayed in a<br />

picture box. The user should be able to add a new book, delete a book, or change the<br />

inventory level of a book in stock. At any time, the user should be able to calculate<br />

the total value of all books, or the total value of the books in either category.

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

Saved successfully!

Ooh no, something went wrong!