{VERSION 6 0 "IBM INTEL NT" "6.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 1 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 257 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Author" -1 19 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 8 8 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Plot" -1 256 1 {CSTYLE "" -1 -1 "Tim es" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 19 "" 0 "" {TEXT -1 0 "" }{TEXT 256 0 "" }{TEXT 257 12 "Assignment 5" }}{PARA 0 "" 0 "" {TEXT 258 9 "Problem 1" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 93 "Use seq a nd rand to write a program to produce a sequence containing 1000 rando m 0's and 1's." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 259 9 "Problem 2" }}{PARA 0 "" 0 "" {TEXT -1 275 "a.) Let's say that you are playing a game in which you are rolling a pair of dice, and 10 is the lucky number that let's you win. Write a program in which the computer rolls the two die and tells you \"You'v e won!\" if a 10 is rolled or \"Sorry, you lost\" in every other case. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 300 "b.) \+ Using this same game, let's say that you win $1 if you roll a 10, $3 i f you roll two 10's in a row, and $20 if you roll three 10's in a row, and each roll costs you $2. Assume you start with $100, and also, si nce you are a conservative gamer, if you earn any profit at all you wi ll stop playing." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 483 "Write a program that that keeps track of the amount of m oney that you have, the total number of rolls that you have made, and \+ how many 10's you've rolled in a row. That last counter will have to \+ reset to 0 each time a number other that 10 is rolled. Also, if you r un out of money, or don't have enough to roll again, than the game mus t end. If you actually win (gain more money than $100), then end the \+ program by telling how much money you have, and how many rolls total i t took." }}{PARA 0 "" 0 "" {TEXT -1 3 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 262 9 "Problem 3" }} {PARA 0 "" 0 "" {TEXT -1 145 "Consider a square whose sides have lengt h 1 with a quarter of a circle inscribed in it (assume it's the first \+ quadrant of the Cartesian plane). " }}{PARA 0 "" 0 "" {GLPLOT2D 168 156 156 {PLOTDATA 2 "6&-%'CURVESG6$7gn7$$\"\"!F)F(7$$\"3emmm;arz@!#>F( 7$$\"3[LL$e9ui2%F-F(7$$\"3nmmm\"z_\"4iF-F(7$$\"3[mmmT&phN)F-F(7$$\"3CL Le*=)H\\5!#=F(7$$\"3gmm\"z/3uC\"F:F(7$$\"3%)***\\7LRDX\"F:F(7$$\"3]mm \"zR'ok;F:F(7$$\"3w***\\i5`h(=F:F(7$$\"3WLLL3En$4#F:F(7$$\"3qmm;/RE&G# F:F(7$$\"3\")*****\\K]4]#F:F(7$$\"3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XT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 77 "By the Pythagorean Theorem, we know that \+ any (x,y) lies within the circle if " }{XPPEDIT 18 0 "sqrt(x^2+y^2) <= 1;" "6#1-%%sqrtG6#,&*$%\"xG\"\"#\"\"\"*$%\"yGF*F+F+" }{TEXT -1 278 ". Imagine that you made a random pencil mark on this graph. Then that point either will or will not lie within the circle. Doing thousands or perhaps millions of such pencil marks could conceivably cover the \+ entire square, and of course the circle, filling its entire area. " } }{PARA 0 "" 0 "" {TEXT -1 136 "We can compare the area of the circle t o the area of the square. Obviously, given a quarter-circle with radi us r, its area is given by " }{XPPEDIT 18 0 "A[c] = Pi*r^2/4;" "6#/&% \"AG6#%\"cG*(%#PiG\"\"\"*$%\"rG\"\"#F*\"\"%!\"\"" }{TEXT -1 60 ". Any square containing this quarter circle will have area " }{XPPEDIT 18 0 "A[s] = r^2;" "6#/&%\"AG6#%\"sG*$%\"rG\"\"#" }{TEXT -1 59 ". Algebr aically manipulating these two equations gives us " }{XPPEDIT 18 0 "Pi = 4*A[c]/A[s];" "6#/%#PiG*(\"\"%\"\"\"&%\"AG6#%\"cGF'&F)6#%\"sG!\"\" " }}{PARA 0 "" 0 "" {TEXT -1 530 "Write a program that generates 100,0 00 (x,y) points between 0 and 1. Have the program generate them to ab out 10 decimal places. Then use the Pythagorean Theorem to find if th ese two points lie withing the circle, and if so, it needs to incremen t a counter. That counter will represent the area of the circle. Whe n it finishes, the program needs to multiply that counter by 4 and div ide by the total number of points (experiment with different numbers o f points...just don't go overboard). You should have an approximation of " }{XPPEDIT 18 0 "Pi;" "6#%#PiG" }{TEXT -1 27 " to several decimal places." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 117 "Remember, the more points you generate, the better the approximat ion will be, but the longer the program will take. " }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 256 " " 1 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} }{MARK "0 14 0" 141 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }