HW8 #3 - %Engineering 6, Spring 2004, Problem 8.3 %Ryan Uy,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 %Engineering 6, Spring 2004, Problem 8.3 %Ryan Uy, 2509 %Section B05, Tues. 3-4 disp('Play the Lottery Game: Enter Your 6 Lucky Numbers') luckynumbers = zeros(6,1) for k=1:6 %loop 6 times and prompt user for luckynumbers luckynumbers(k) = input('Enter number: ') end numbersvalid = 1 for k=1:6 %loop six times to check if each number is valid if luckynumbers(k)<1 | luckynumbers(k)>49 numbersvalid = 0 break end for j=1:6 numbersvalid = 0 break end end end if numbersvalid == 0 %if numbers were ever invalid, numbersvalid flag would have been set to 0 disp('Invalid numbers. Program halted.') end if numbersvalid == 1 %only executes the code below if numbersvalid = 1, i.e. numbers are all valid rand('state',97) zeromatchestally = 0 onematchtally = 0 twomatchestally = 0 threematchestally = 0 fourmatchestally = 0 fivematchestally = 0 sixmatchestally = 0 lottonums = zeros(6,1) for i=1:5000 %loop 5000 times for 5000 different drawings matches = 0 lottonums = rcu_lottery(lottonums)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/22/2011 for the course ENG 006 taught by Professor Lagerstrom during the Spring '06 term at UC Davis.

Page1 / 6

HW8 #3 - %Engineering 6, Spring 2004, Problem 8.3 %Ryan Uy,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online