Presentation is loading. Please wait.

Presentation is loading. Please wait.

Console.WriteLine(“Good luck!”);

Similar presentations


Presentation on theme: "Console.WriteLine(“Good luck!”);"— Presentation transcript:

1

2 Console.WriteLine(“Good luck!”);
PC01 Term 2 Test Console.WriteLine(“Good luck!”);

3 This term we have covered:
Introduction This term we have covered: While loops Do-while loops For loops Bubble sort Linear search It’s time to test your knowledge!

4 Create a random number generator
Test Exercise 1 Make a new project Create a random number generator Declare an integer variable called “maximum” and give it a random value between 10 and 20 Using a for loop, output all numbers from maximum down to zero (inclusive) For example, if maximum = 10, your output should be “ ”

5 Test Exercise 2 Create a for loop that goes over all numbers between 0 and 10 and uses a variable called i as a counter Inside, create another for loop that also goes over numbers between 0 and 10 and uses j as a counter Using Console.Write, output a tab (use the “\t” escape sequence) followed by i*j Then, after the inner for loop (but still inside the outer loop) use Console.WriteLine to move on the next line

6 Your output should look like this:
Test Exercise 2 Your output should look like this:

7 Declare an boolean variable and call it repeat and set it to false
Test Exercise 3 Declare an boolean variable and call it repeat and set it to false Declare an array of strings and call it names Fill it with at least five different names Declare a do while loop It should print a random name from names array

8 If they type “yes” then set repeat to true
Test Exercise 3 Still inside the loop, ask the user if they want to see another name and then get their input and save in a string variable If they type “yes” then set repeat to true If they type anything else set it to false Repeat the loop if repeat is equal to true

9 Move on to the next slide for some extra exercises
END OF TEST Move on to the next slide for some extra exercises

10 Using an if statement, compare every element in names with longestName
Test Exercise 4 Declare a string variable called “longestName” and set it to an empty string Create a for loop that starts at 0 and ends at names.Length (or names.GetLength(0)) Using an if statement, compare every element in names with longestName If the current element’s length is greater than longestName’s length, set longestName to the current name

11 This flowchart might help you:
Test Exercise 4 This flowchart might help you:

12 Extension (not marked)
If you’re done, create a rock-paper-scissors game (player vs ai) Use a while loop to keep the game running until someone wins at least three times


Download ppt "Console.WriteLine(“Good luck!”);"

Similar presentations


Ads by Google