Download presentation
Presentation is loading. Please wait.
Published byHoratio Cannon Modified over 9 years ago
1
Dr. Tami Meredith Saint Mary's & Dalhousie Universities
2
"You can't get to Spuzzum if you don't know where Spuzzum is!" Know what you're supposed to do. 1. What is your data? Identify what you start with. Identify what you're supposed to finish with. 2. What is your algorithm? Decide how to manipulate the data. Develop a set of steps that solve the problem. Look for "sub problems" – do easy stuff first and leave harder parts for later.
3
Test after each step and fix the faults before moving on. Always have it working. 1. Create the starting framework (an empty program). 2. Define the variables. 3. Program the input and output. 4. Program the algorithm in small pieces, testing each piece as you go.
4
Professional programmers spend a LOT of time testing. Nothing can be tested well enough. Testing is your "Last Line of Defense."
5
Lots of computers don't use windowing systems and even those that do often don't use windows. The console is a text-based format for entering and viewing data. A console is like an old (1970s and before) style, pre-windows computer. Console output is easy to send to files. Console input is easy to get from files.
6
Dim input As String input = Console.ReadLine() Console.Out.WriteLine(input) Console.Out.Write(input)
7
The console closes (i.e., disappears) when the program is over. So that we can read what is on it, we need to "pause" the program somehow. The most common technique is simply to get some input from the user, causing the computer to wait until any key is pressed, and then throw it away. Just use: Console.ReadLine()
8
Strings are sequences of characters. Every character has an "index number" (also just called the "index"). The first character is at index 0. The index is the number of characters that come before it in the string. Quotes are not part of the string, they just show the computer where the string starts and stops. "I wantpizza!" 0123456789101112
9
Strings have a length Dim name As String = "Justin Bieber" Dim slen As Integer = name.Length We can access the character at any index For example, to access the third character we put the index after the string in parentheses name(2) Remember that name(0) would be the first character
10
We can use loops to look at all the characters in a string! The following writes the string name to the screen one character per line For i = 0 To name.Length-1 Console.Out.WriteLine(name(i)) Next i
11
Atbash replaces a with z, b with y, c with x, … and so on. It is a way of "coding" a message to hide it's contents. For example: "Hello" becomes "Svool" We can track replacements with a small table: abcdefghijklmnopqrstuvwxyz zyxwvutsrqponmlkjihgfedcba
12
Task: Create a console version of Atbash. Encodes strings. Preserves case (capitals stay as capitals). Leaves spaces and punctuation unchanged.
13
1. Build a framework 2. Define input and output 3. Sketch the algorithm with comments 4. Get the input and output working 5. Implement the algorithm in pieces 6. Test and repair as much as we can
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.