Return to Unit Menu | | | Terms of Use  |

When you are preparing to write a computer program, you need to have a plan. You need to think through the problem and have a plan as to how you will proceed before you begin typing.

When preparing a very small program, you may be able to organize your thoughts in your head. But, as programs get longer and more complicated, you will need some type of outline to keep your thoughts straight and save you the time of having to re-write sections because you forgot a component of the problem.

When faced with a complex programming situation, computer programmers first analyze the problem and determine what the program is going to do. They then design a plan of attack as to how the program is going to do it.
Determining the step-by-step process to be used by the program is called developing an algorithm. Programming algorithms may be expressed in the form of an organizational flowchart, complete with flowcharting symbols. It is more popular, however, to organize the program in writing using a combination of English and code, referred to as pseudocode.

During the development of the pseudocode, you will want to list the variable names you will be using and what they represent in the program. Include any formulas or computations that are needed, as well as any specific means of output. You will basically be following the programming process from start to finish. As a new programmer, you will be listing more details than may be needed by an experienced programmer.


Problem: Horses are measured at their withers (the front top of their back) in "hands". A hand is defined to be 4 inches. A horse that is 15 hands is 60 inches tall at its withers. A horse that is 15.2 hands is 62 inches tall. The subdivision of a hand is a base 4 system, so a 64 inch horse is 16.0 hands (not 15.4). Prepare a program that when given the height of a horse in inches, will convert the height to hands. horseheight

Let int height = height of horse in inches
       int hands = height of horse in full hands
       int partial = the remaining inches in a hand
Obtain the height from the user to nearest inch.
Scanner to obtain data (remember import statement).
Convert height to hands using division and modulus
       hands = height /4 (full hands from integer division)
       partial = height % 4 (partial hands from remainder)
Print out the complete height in hands using a "literal decimal point" between the full hands and partial hands.
Close the scanner.

Coded Program:

 Return to Unit Menu | | | Terms of Use  |

Notice: These materials are free for your on-line use at this site, but are not free for the taking.
Please do not copy these materials or re-post them to the Internet, as it is copyright infringement.
If you wish hard-copies of these materials, refer to our subscription area,
Help us keep these resources free. Thank you.