Presentation is loading. Please wait.

Presentation is loading. Please wait.

Reindeer don't go to public school, they’re elf taught.

Similar presentations


Presentation on theme: "Reindeer don't go to public school, they’re elf taught."— Presentation transcript:

1

2 Reindeer don't go to public school, they’re elf taught.
PC01 Term 1 Consolidation Reindeer don't go to public school, they’re elf taught.

3 Today we are going to consolidate everything we’ve learnt so far
Introduction Today we are going to consolidate everything we’ve learnt so far Feel free to pick any topic you want All work should be done in the same solution

4 Index Variables & Data types Random number generators If statements
Arrays Fixing errors Click me Click me Click me Click me Click me

5 Variables Make 5 variables: string input bool isNumber double decimalNumber int wholeNumber char character Get some input from the console using Console.ReadLine() and save it in input

6 Save the result in isNumber
Variables 2 Use Double.tryParse(input, out decinalNumber) to get a decimnal number from the console Save the result in isNumber Take the decimal result and save it in your wholeNumber variable You will need to use casting

7 Using casting, save your value from wholeNumber in character
Variables 3 Using casting, save your value from wholeNumber in character Print all 5 variables to the console Should get something like this:

8 Random number generators 1
Create 3 random number generators Call them rng1, rng2 and rng3 Put “1”(no speech marks) in brackets after Random() for rng1 and rng2 Leave brackets for rng3 empty

9 Random number generators 2
Generate three random numbers between 1 and 100 (inclusive!) using rng1 and print them Repeat the same for rng2 and rng3 Every time you run your program, six numbers will stay the same and three numbers will be different every time

10 If statements 1 Create two variables: boolean snow int temperature Make a random number generator and assign random values to both variables You can use “snow = (rng.Next(2) == 0)” to generate a random boolean For temperature, use rng.Next(-10, 11);

11 Run your program. Make sure it prints something every time you run it!
If statements 2 Make an if statement If it is not snowing and temperature is less than zero output “The snowman is feeling great!” If temperature is greater or equal to zero, print “Oh no, the snowman is melting!” Otherwise, print “There is so much snow that I can’t find the snowman!” Run your program. Make sure it prints something every time you run it!

12 Create an array of strings and call it cats
Arrays 0 Create an array of strings and call it cats Using curly brackets, save three cat names in it Create another array of strings called dogs This time, use “new string[3]” and assign it three dog names using dogs[index] Make a random number generator

13 Pick a random cat form cats and save it in a variable
Arrays 1 Pick a random cat form cats and save it in a variable It’s index must be between 0 and .Length (non-inclusive) Pick a random dog and save it as well Print both of them to the console Using an if statement, output which name is longer You will need to use “.Length”

14 Arrays 2 Create a string variable called input and get it a value from the console Create an array of characters called letters and say that it’s equal to “input.ToCharArray()” This will split your string into an array of characters

15 Create a new String variable called result
Arrays 3 Create a new String variable called result Give it the following value: String.Join(“la”, letters); It will insert “la” between all letters Print your result to the console Test your program, it should convert your input like this: banana -> blaalanlaalanlaa

16 Debugging is a vital skill for any programmer
Fixing errors Debugging is a vital skill for any programmer It’s time for you to get a bit of practise! Click here: … or type this link: goo.gl/Xb9sy5 You will need to unzip the folder (right click -> Extract all…) and double click on FixMe.sln Download the program

17 Enjoy your Christmas break!
That’s it for this term! Enjoy your Christmas break!


Download ppt "Reindeer don't go to public school, they’re elf taught."

Similar presentations


Ads by Google