# Gridrowcolumn computermark endif return getrow if

• Homework Help
• 50
• 94% (47) 44 out of 47 people found this document helpful

This preview shows page 48 - 50 out of 50 pages.

grid[row][column] = COMPUTER_MARKendifreturngetRow()if position mod 3 = 0 thenrow = position/3 – 1elserow = position/3endifreturn getColumn()num columnif position mod 3 = 0 thencolumn = 2elsecolumn = position mod 3 - 1endifreturn checkWinner()winner = 0x = 0while x < SIZE AND winner = 0if(grid[x][0] equals grid[x][1] ANDgrid[x][0] equals grid[x][2]) thenwinner = 1endif48
Programming Logic and Design, 7eSolutions 8-x = x + 1endwhilex = 0while x < SIZE AND winner = 0if(grid[0][x] equals grid[1][x] ANDgrid[0][x] equals grid[2][x]) thenwinner = 1endifx = x + 1endwhileif(grid[0][0] equals grid[1][1] ANDgrid[1][1] equals grid[2][2]) thenwinner = 1endifif(grid[0][2] equals grid[1][1] &&grid [1][1] equals grid[2][0])winner = 1endifreturnUp for Discussion17.Now that you are becoming comfortable with arrays, you can see that programming is a complex subject. Should all literate people understand how to program? If so, how much programming should they understand?Answer:Student answers will vary. In the business world, it pays to understand a little bit about programming so that you understand what is possible - what types of calculations can be made, what types of reports are reasonable to request from the programming department. Even if you are not a programmer, understanding some programming might help you analyze problems. For example, if you work in the Payroll Department and receive a report in which the last person alphabetically is missing, you might recognize this as a sort algorithm programming error (losing the last array element) and be able to talk to the right person to rectify it.18.What are language standards? At this point in your study of programming, what do they mean to you?Answer:For most programming languages, you can locate published standards on the web or in reference books. Standards recommend 49
Programming Logic and Design, 7eSolutions 8-conventions for naming and capitalizing program components, such as variables and method names, indentation, appropriate points at which to break long lines of code, and so on. Having standards can help you more quickly understand others’ programs.19.This chapter discusses sorting data. Suppose that a large hospital hires you to write a program that displays lists of potential organ recipients. The hospital’s doctorswill consult this list if they have an organ that can be transplanted. The hospital administrators instruct you to sort potential recipients by last name and display them sequentially in alphabetical order. If more than 10 patients are waiting for a particular organ, the first 10 patients are displayed; a doctor can either select one or move on to view the next set of 10 patients. You worry that this system gives an unfair advantage to patients with last names that start with A, B, C, and D. Should you write and installthe program? If you do not, many transplant opportunities will be missed while the hospital searches for another programmer to write the program. Are there different criteria you would want to use to sort the patients?