CS 200 - Programming I Jim Williams, PhD.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Begin Java Pepper. Objectives What is a program? Learn the basics of your programming tool: BlueJ Write a first Java program and see it run Make some.
AP Computer Science. Google Interview Question You are given 8 identical looking balls. One of them is heavier than the rest of the 7 (all the others.
How do we make our Welcome.java program do something? The java in our Welcome.java file won’t do anything by itself. We need to tell the computer to execute.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
How do we make our HelloTester.java program do something? The java in our HelloTester.java file won’t do anything by itself. We need to tell the computer.
Introduction to Java.
Writing algorithms using the while-statement. Previously discussed Syntax of while-statement:
Writing algorithms using the for-statement. Programming example 1: find all divisors of a number We have seen a program using a while-statement to solve.
Computer Programming Lab(4).
The break and continue statements. Introduction There are 2 special statements that can affect the execution of loop statements (such as a while-statement)
Computer Programming Lab(5).
IB Computer Science II Paul Bui
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Intro to Java Programming  A computer follows the instruction precisely and exactly.  Anything has to be declared and defined before it can be used.
From BlueJ to NetBeans SWC 2.semester.
CS107 Introduction to Computer Science Java Basics.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Java TA Session 1. Software Java Runtime Environment (JRE) java.exe Java Development Kit (JDK) java.exe, javac.exe Version 1.6 = Version 6, Version 1.7.
OOP (Java): Simple/ OOP (Java) Objectives – –give some simple examples of Java applications and one applet 2. Simple Java Programs Semester.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Input & Output In Java. Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
1 Debugging. 2 A Lot of Time is Spent Debugging Programs Debugging. Cyclic process of editing, compiling, and fixing errors. n Always a logical explanation.
Boolean expressions, part 2: Logical operators. Previously discussed Recall that there are 2 types of operators that return a boolean result (true or.
BUILDING JAVA PROGRAMS CHAPTER 1 ERRORS. 22 OBJECTIVES Recognize different errors that Java uses and how to fix them.
Working with arrays (we will use an array of double as example)
Assignment statements using the same variable in LHS and RHS.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
CS110 Programming Language I Lab 4: Control Statements I Computer Science Department Spring 2014.
CS 4244: Internet Programming Network Programming in Java 1.0.
Introduction Chapter 1 8/31 & 9/1 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
Using the while-statement to process data files. General procedure to access a data file General procedure in computer programming to read data from a.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Reading input from the console input. Java's console input The console is the terminal window that is running the Java program I.e., that's the terminal.
Introduction to array: why use arrays ?. Motivational example Problem: Write a program that reads in and stores away 5 double numbers After reading in.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
Foundations of Programming: Java
Chapter 1 – Introduction
Exercise 1- I/O Write a Java program to input a value for mile and convert it to kilogram. 1 mile = 1.6 kg. import java.util.Scanner; public class MileToKg.
Java Course Review.
Chapter 3 GC 101 Java Fundamentals.
Compiling and Running a Java Program
Programming without BlueJ Week 12
Comp Sci 200 Programming I Jim Williams, PhD.
CS Programming I Jim Williams, PhD.
Something about Java Introduction to Problem Solving and Programming 1.
Comp Sci 302 Introduction to Programming
While Statement.
CS Week 3 Jim Williams, PhD.
Introduction CSC 111.
CS Week 3 Jim Williams.
CS 200 Primitives and Expressions
CS 200 Primitives and Expressions
Introduction to Java Brief history of Java Sample Java Program
Lecture Notes - Week 2 Lecture-1. Lecture Notes - Week 2 Lecture-1.
IB Computer Science II Paul Bui
Zorah Fung University of Washington, Spring 2015
CS Week 2 Jim Williams, PhD.
F II 2. Simple Java Programs Objectives
Ben Stanley for gAlpha gALPHA free, four-week venture-creation workshop designed to help entrepreneurially-minded students and technologists create high-growth.
CS Programming I Jim Williams, PhD.
Zorah Fung University of Washington, Winter 2016
Presentation transcript:

CS 200 - Programming I Jim Williams, PhD

Who Am I? My Interests: CS Education, specifically the teaching and learning of programming. PhD in Computer Science, minor in Educational Psychology Husband, Father, Coach, Traveller, ... http://pages.cs.wisc.edu/~jimw/

Comp Sci 200 - Programming I What is Computer Science & Programming? Tracing a Java Program Organization of Course Who is here? Programming Process

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.

Enjoyment and Satisfaction Lots of puzzles, problem solving and challenge Opportunity to create something from nothing Opportunity to apply to any field Many enjoy these aspects of Computer Science and find a lot of satisfaction when successful.

A Java Program import java.util.Scanner; public class ReadNumber { public static void main(String[] args) { Scanner input = new Scanner(System.in); double num = input.nextDouble(); System.out.println("Number entered: " + num); } Java is a text language for controlling the computer. Programs are called "code" for a reason. Decode (read) "convert (a coded message) into intelligible language." [Google Dictionary]

Java Visualizer Demo Link available on right side of course website. https://cs200-www.cs.wisc.edu/wp/

https://cs200-www.cs.wisc.edu/wp/ http://pages.cs.wisc.edu/~cs200

Organization of Course: Study Cycle

When Women Stopped Coding http://www.npr.org/sections/money/2014/10/21/357629765/when-women-stopped-coding

Who is here?

Understand vs. Apply Steph Curry, NBA Golden State Warriors Basketball Analogy Demonstration vs. Practice Declarative Knowledge vs Procedural Knowledge Importance of Practice for learning If you watch the same video or even 10 different videos on how to shoot a basketball do you get better at shooting a basketball? Steph Curry, NBA Golden State Warriors

Declarative and Procedural Knowledge Declarative: Knowledge about something talk about a bike CS terms and Java syntax Procedural: Knowing how to do something ride a bike solve a problem systematically write in Java

Edit-Compile-Run Cycle From the command-line: notepad (Editor) javac (Compiler) java (Virtual Machine)

File name Cat.txt Cat.java Cat.class Cat For the class named Cat, what is the name of the file that the compiler creates and is provided to the Java Virtual Machine to run? Cat.class

Compile For the class named Cat, what command would compile the class? notepad Cat.java javac Cat.java java Cat.java java Cat For the class named Cat, what command would compile the class? javac Cat.java

Edit-Compile-Run Cycle Users Editor (Virtual) Machine Compiler Hello.java Hello.class Computer Files Programmer

Various Errors Naming/Saving Syntax/Compile time Runtime & Logic Files Editor (Virtual) Machine Compiler Hello.java Hello.class Computer Files Programmer

Programming Process Study the Problem Design an Algorithm to Solve the Problem Write in Code (e.g., Java) Compile the Code Run the code Repeat

Problem Obtain 3 numbers from the user. IF the 3 numbers could be lengths of the sides of a triangle, output "COULD be lengths of sides of a triangle" OTHERWISE output "Cannot be lengths of sides of a triangle" import java.util.Scanner; public class ClassNameHere { public static void main(String[] args) { Scanner input = new Scanner(System.in); double one = input.nextDouble(); double two = input.nextDouble(); double three = input.nextDouble(); if ( one + two > three && one + three > two && two + three > one) { System.out.println("COULD be the lengths of the sides of a triangle."); } else { System.out.println("Cannot be the lengths of the sides of a triangle."); } Reference: Frank Ackerman

Problem Write a program to calculate the cost to carpet a floor. Tips for Solving Programming Problems Java Visualizer starting point