Comp Sci 302 Introduction to Programming Jim Williams, PhD
What is Computer Science? What is Programming? With a name like computer science, you might think it is all about the computer. Core principles: Abstractions and algorithms This course: Learning to give instructions to the computer. Read and Write Java
What is Computer Science? The study of the computer itself as well as how computers are applied to solve problems in any field. What is Programming? Designing algorithms and writing them in a language a computer can execute.
In Computer Science Lots of puzzles, problem solving and challenge. Opportunity to create something from nothing Opportunity to apply to any field Many enjoy these and find a lot of satisfaction when successful.
CS Core Principles: Algorithms: A step-by-step set of operations to be performed. Abstraction: a technique for managing complexity.
Bloom's Taxonomy of Educational Goals 6. Create: Produce new or original work 5. Evaluate: Justify a stand or decision 4. Analyze: Draw connections among ideas 3. Apply: Use information in new situations 2. Understand: Explain ideas or concepts Remember: Recall facts and basic concepts What level is expected in high school, college? What is required to "get an A"? What is required in order to teach? https://cft.vanderbilt.edu/guides-sub-pages/blooms-taxonomy/
Understand vs. Apply Steph Curry, NBA Golden State Warriors Basketball Analogy Demonstration vs. Practice Declarative Knowledge vs Procedural Knowledge Importance of Practice for learning Steph Curry, NBA Golden State Warriors
Who is in the class?
When Women Stopped Coding http://www.npr.org/sections/money/2014/10/21/357629765/when-women-stopped-coding
Education, Race, Women & Computing Unlocking the Clubhouse By Jane Margolis and Allan Fisher Stuck in the Shallow End By Jane Margolis
Memory, Sequence, Assignment int i; int j; i = 5; j = i; Briefly Explain Draw a picture of memory Walk through Demonstrate in Java Visualizer
What are the values in a, b & c? int a = 5; int b = 7; int c = a; b = c; a = b;
Swap values in a & b int a = 5, b = 3; Write code to swap values in a & b. a = b; b = a; c = b; b = c; c = a; a = c; Google "swapping values without third variable" for many creative ways.
Print Out int numCars = 9; int numTrucks = 4; System.out.print( numCars ); System.out.print( numCars + numTrucks); System.out.println( "numCars" + numTrucks); Ask for results Demonstrate in Java Visualizer
Print Out Starting with: int a = 5; int b = 3; Produce output: a has 5 System.out.print(a has 5); System.out.println(b has 3); System.out.print(a + " has " + 5); System.out.print(b + " has " + 3); System.out.println("a has 5"); System.out.print("b has 3"); System.out.print("a has " + a); System.out.println("b has " + b); Starting with: int a = 5; int b = 3; Produce output: a has 5 b has 3
Escape Sequences Special character sequences within a String \n \" \\ \t System.out.print( "hello\n\t\"hi\"\ngoodbye"); hello "hi" goodbye
What is printed out? System.out.print( "Fred says \"hello\"\nthis morning."); Fred says "hello" this morning. Fred says hello\nthis morning. Fred says \"hello\"
Questions (Degrees Fahrenheit – 32) x 5 / 9 = Degrees Celsius What symbols have different meanings in Java? What changes must be made to implement this equation in Java? Retrieval practice importance of committing to an answer
Eclipse IDE Opening project, copying in files Style and Commenting Guides Strings I/O Calling methods Compiler & Runtime Errors Scanner reading a number
Review (Degrees Fahrenheit – 32) x 5 / 9 = Degrees Celsius What symbols have different meanings in Java? What changes must be made to implement this equation in Java?
My List X vs * equals (==) vs assignment (=) value is stored on the left hand side of assignment (=) operator Variables: name areas of computer memory, declare before use, declare type of data, initialize Variable names: start with letter, include letters numbers and _, but no spaces Conventions: camelCasing, spell out names Semicolon at the end of statements
Read In Values Recall: import java.util.Scanner; Scanner input = new Scanner( System.in); int age = input.nextInt(); String name = input.nextLine(); Use print statements to see what is happening as code is executing.
What are values of variables? name: Minsub\n age: 22\nCS major: name: Minsub\n22\CS age: name: Minsub age: 22 String note = "Minsub\n22\nCS"; Scanner input = new Scanner( note); String name = input.nextLine(); int age = input.nextInt(); String major = input.nextLine();
P1 - M0 Available P1 - Individual work Style and Commenting 4 weekly milestones, Due 8am Thursday P1 - Individual work Discuss concepts, don’t share assignment code Style and Commenting