CSE 142 Lecture Notes - Lecture 14: Dont

96 views4 pages
Verified Note

Document Summary

For ( int i = 0; i < 5; i++) { 1 // this program demonstrates some basic usage of booleans types. Notice the use of good "boolean zen" and the. 3 // "innocent until proven guilty" pattern in the gotheads. 8 public static void main(string[] args) { 16 for ( int i = 0; i < 5; i++) { 26 // write a method countheads that takes an integer and a random. 27 // object as parameters and simulates flipping a coin the given. The method hsould return the number of flips. 31 // int numflips - the maximum number of times to flip. 32 // random rand - the random object to use for randomization. 33 public static int countheads( int numflips, random rand) { // bad boolean zen - don"t do this! 35 for ( int i = 0; i < numflips; i++) { 44 // write a method gotheads that takes an integer and a random.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents