Presentation is loading. Please wait.

Presentation is loading. Please wait.

Welcome back to Software Development!

Similar presentations


Presentation on theme: "Welcome back to Software Development!"— Presentation transcript:

1 Welcome back to Software Development!

2 Random Numbers

3 Random Numbers What is a random number?

4 Random Numbers What is a random number? Basically a roll of the dice

5 Random Numbers What is a random number? Basically a roll of the dice
In a program, is a way of simulating chance or uncertainty

6 Random Numbers What is a random number?
Basically a roll of the dice In a program, is a way of simulating chance or uncertainty .NET gives us a way of generating random numbers

7 Random Numbers What is a random number?
Basically a roll of the dice In a program, is a way of simulating chance or uncertainty .NET gives us a way of generating random numbers Random class (in the System namespace)

8 Random Numbers What is a random number?
Basically a roll of the dice In a program, is a way of simulating chance or uncertainty .NET gives us a way of generating random numbers Random class (in the System namespace) Supports both int and double

9 Random Numbers What is a random number?
Basically a roll of the dice In a program, is a way of simulating chance or uncertainty .NET gives us a way of generating random numbers Random class (in the System namespace) Supports both int and double Seed

10 Random Numbers What is a random number?
Basically a roll of the dice In a program, is a way of simulating chance or uncertainty .NET gives us a way of generating random numbers Random class (in the System namespace) Supports both int and double Seed: lets you start the random # sequence the same each time

11 Random Numbers What is a random number?
Basically a roll of the dice In a program, is a way of simulating chance or uncertainty .NET gives us a way of generating random numbers Random class (in the System namespace) Supports both int and double Seed: lets you start the random # sequence the same each time Range

12 Random Numbers What is a random number?
Basically a roll of the dice In a program, is a way of simulating chance or uncertainty .NET gives us a way of generating random numbers Random class (in the System namespace) Supports both int and double Seed: lets you start the random # sequence the same each time Range: can say give me random # between this and that

13 Random Numbers

14 Random Numbers Random rndNum = new Random();

15 Random Numbers Random rndNum = new Random(); int intNum;

16 Random Numbers Random rndNum = new Random(); int intNum;
intNum = rndNum.Next(); // no bound

17 Random Numbers Random rndNum = new Random(); int intNum;
intNum = rndNum.Next(); // no bound intNum = rndNum.Next(20); // upper bound

18 Random Numbers Random rndNum = new Random(); int intNum;
intNum = rndNum.Next(); // no bound intNum = rndNum.Next(20); // upper bound intNum = rndNum.Next(10,20); // lower & upper bound

19 Random Numbers

20 Random Numbers Random rndNum = new Random();

21 Random Numbers Random rndNum = new Random(); double dblNum;

22 Random Numbers Random rndNum = new Random(); double dblNum;
dblNum = rndNum.NextDouble(); // no bound

23 Random Numbers Random rndNum = new Random(); double dblNum;
dblNum = rndNum.NextDouble(); // no bound dblNum = rndNum.NextDouble(20); // upper bound

24 Random Numbers Random rndNum = new Random(); double dblNum;
dblNum = rndNum.NextDouble(); // no bound dblNum = rndNum.NextDouble(20); // upper bound dblNum = rndNum.NextDouble(10,20); // lower & upper bound

25 Your Turn

26 Your Turn In your teams, write a program that:

27 Your Turn In your teams, write a program that:
Generates a randomized number

28 Your Turn In your teams, write a program that:
Generates a randomized number Display the random number

29 Your Turn In your teams, write a program that:
Generates a randomized number Display the random number Based on that number

30 Your Turn In your teams, write a program that:
Generates a randomized number Display the random number Based on that number Using a switch statement

31 Your Turn In your teams, write a program that:
Generates a randomized number Display the random number Based on that number Using a switch statement Print a different message for each number

32 Your Turn In your teams, write a program that:
Generates a randomized number Display the random number Based on that number Using a switch statement Print a different message for each number You must support at least 3 different output messages

33 Your Turn In your teams, write a program that: IF you get stuck…
Generates a randomized number Display the random number Based on that number Using a switch statement Print a different message for each number You must support at least 3 different output messages IF you get stuck…

34 Your Turn In your teams, write a program that: IF you get stuck…
Generates a randomized number Display the random number Based on that number Using a switch statement Print a different message for each number You must support at least 3 different output messages IF you get stuck… Switch statement: you can use the SwitchDemo program on page 52 as guidance

35 Your Turn In your teams, write a program that: IF you get stuck…
Generates a randomized number Display the random number Based on that number Using a switch statement Print a different message for each number You must support at least 3 different output messages IF you get stuck… Switch statement: you can use the SwitchDemo program on page 52 as guidance Random numbers: you can use the Roller program on page 56 as guidance

36 Your Turn In your teams, write a program that: IF you get stuck…
Generates a randomized number Display the random number Based on that number Using a switch statement Print a different message for each number You must support at least 3 different output messages IF you get stuck… Switch statement: you can use the SwitchDemo program on page 52 as guidance Random numbers: you can use the Roller program on page 56 as guidance You have the remainder of the period…

37 Clear and Unclear Windows


Download ppt "Welcome back to Software Development!"

Similar presentations


Ads by Google