VIEWS: 357 PAGES: 1 POSTED ON: 7/3/2010
BIT 115: Introduction to Programming: Java Creating Algorithms with Pseudo code This is an example of pseudocode – it's written in a particular style, which obviously isn't Java, and isn't normal English, either. Yet it's reasonable to expect someone to be able to understand it without much training. It's also easy to see how one might use programming language constructs (like IF, WHILE, etc) to express this. Pseudocode is about half way between English and a real programming language. Brushing Teeth Algorithm Precondition: toothpaste tube, toothbrush, and a Put down toothbrush glass of water are sitting on counter. Sink is Pick up toothpaste tube nearby. Replace tube cap Put down toothpaste tube Postcondition: teeth are clean //Prepare to brush SERVICES Pick up toothpaste tube with right hand Remove tube cap Remove tube cap if twist-off cap then Pick up toothbrush with left hand while cap does not pull off, turn cap Spread toothpaste on toothbrush counter-clockwise Put down toothpaste put cap down Transfer toothbrush to right hand if flip-top cap then push open top of cap Wet toothbrush bristles with water from sink Open mouth wide Replace tube cap Put bristle end of toothbrush in mouth if flip-top cap then push closed top of cap if twist-off cap then //Brush pick up cap Repeat for one minute position cap over tube end with threads Brush lower right next to tube opening Repeat for one minute while cap continues to turn, turn cap Brush lower left clockwise Remove toothbrush from mouth Rinse Repeat for 1/2 minute Rinse Brush upper right Pick up glass of water Repeat for 1/2 minute Move glass until rim touches mouth Brush upper left Take a sip of water into mouth Remove toothbrush from mouth Put glass of water down Rinse Repeat for 1/2 minute Close teeth Swish water in mouth Repeat for 1/2 minute Spit water into sink Brush front of teeth Remove toothbrush from mouth Brush <area of mouth> Rinse Position toothbrush bristles over teeth in <area of mouth> //Clean up move brush forward and backward five Rinse out toothbrush times.
Pages to are hidden for
"Brushing Teeth"Please download to view full document