Homework 6
Write a program for Casino Night 2000. We have a bowl with "w" white and "b" black balls. What is the probability to get "bet" or less whites if "d" drawings are made?
The mathematical formula for w=6, b=4, d=7 and bet=1 would be
( 7 ) 1 6 ( 7 ) 0 7
( 1 ) * (.6) * (.4) + ( 0 ) * (.6) * (.4)
If you use the "pow" function, compile with "gcc -lm".
You can check your results by comparing them with what the executable ~jmache/cs1/bino gets.
In order to achieve modularity and simplicity, I urge you to use several functions (program and test them one by one), probably in the following way:
main
|
binomialsum
|
binomial
/ | \
chose pow pow
/ | \
factorial fa. factorial
Remember:
It is due Mo 3/8, late homeworks will be penalized !
You will be graded on:
- correctness: (6 points)
- correct algorithm and results (incl. thorough testing)
- robustness (e.g. no division by zero)
- following the specification (e.g. output specification)
- style: (4 points)
- use of comments
- indentation (use TAB key in emacs)
- meaningful variable and function naming
- simplicity, modularity etc.