CS Programming I: Programming Process

Similar documents
CS Programming I: Programming Process

CS Programming I: Programming Process

CS Programming I: Primitives and Expressions

CS Programming I: Inheritance

CS Programming I: Using Objects

CS Programming I: Using Objects

CS Programming I: ArrayList

CS Programming I: Branches

CS Programming I: Exceptions

CS Programming I: Arrays

CS Programming I: Branches

CS Programming I: Exceptions

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics

Lecture Set 2: Starting Java

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

CS 177 Recitation. Week 1 Intro to Java

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Lecture Set 2: Starting Java

CS Programming I: File Input / Output

CS Programming I: File Input / Output

Welcome to the Primitives and Expressions Lab!

Java Bytecode (binary file)

Supplementary Test 1

First Java Program - Output to the Screen

CS Programming I: Classes

COMP 110/L Lecture 13. Kyle Dewey

COMP 202 Java in one week

Lab # 2. For today s lab:

More Things We Can Do With It! Overview. Circle Calculations. πr 2. π = More operators and expression types More statements

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

CS 302: Introduction to Programming

Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming

CS 106 Introduction to Computer Science I

CS 374 Fall 2014 Homework 2 Due Tuesday, September 16, 2014 at noon

Java: Comment Text. Introduction. Concepts

Università degli Studi di Bologna Facoltà di Ingegneria. Principles, Models, and Applications for Distributed Systems M

COMP 110 Project 1 Programming Project Warm-Up Exercise

Introduction to Java Applications

Table of Contents Date(s) Title/Topic Page #s. Abstraction

Introduction to Java Applications; Input/Output and Operators

when you call the method, you do not have to know exactly what those instructions are, or even how the object is organized internally

Review for Test 1 (Chapter 1-5)

COSC 123 Computer Creativity. Introduction to Java. Dr. Ramon Lawrence University of British Columbia Okanagan

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

An overview of Java, Data types and variables

Entry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process

Welcome to the Using Objects lab!

Introduction to Software Development (ISD) David Weston and Igor Razgon

COMP 110 Introduction to Programming. What did we discuss?

CS110: PROGRAMMING LANGUAGE I

Entry Point of Execution: the main Method. Elementary Programming. Compile Time vs. Run Time. Learning Outcomes

Chapter 2: Data and Expressions

Mr. Monroe s Guide to Mastering Java Syntax

COMP 202. Built in Libraries and objects. CONTENTS: Introduction to objects Introduction to some basic Java libraries string

STUDENT LESSON A7 Simple I/O

Programming with Java

COMP 202. Java in one week

Homework 1 Due Tuesday, January 30, 2018 at 8pm

4. Java language basics: Function. Minhaeng Lee

Section 2: Introduction to Java. Historical note

Tester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time

Elementary Programming

Introduction to Programming Using Java (98-388)

Getting started with Java

CS 101 Spring 2007 Midterm 2 Name: ID:

Program Fundamentals

Java: Classes. An instance of a class is an object based on the class. Creation of an instance from a class is called instantiation.

Chapter 2, Part I Introduction to C Programming

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style

Chapter 2: Data and Expressions

Full file at

2.8. Decision Making: Equality and Relational Operators

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015

COMP 202 Java in one week

CS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017

Anatomy of a Java Program: Comments

Algorithms and Programming I. Lecture#12 Spring 2015

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

St. Edmund Preparatory High School Brooklyn, NY

Controls Structure for Repetition

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

Life Without NetBeans

Section 2.2 Your First Program in Java: Printing a Line of Text

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

Chapter 2: Data and Expressions

CS 152: Data Structures with Java Hello World with the IntelliJ IDE

CS 106 Introduction to Computer Science I

PRIMITIVE VARIABLES. CS302 Introduction to Programming University of Wisconsin Madison Lecture 3. By Matthew Bernstein

CSCE 145 Exam 1 Review. This exam totals to 100 points. Follow the instructions. Good luck!

Strings, Arrays, A1. COMP 401, Spring 2015 Lecture 4 1/20/2015

Course Outline. Introduction to java

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program?

Lecture Notes. System.out.println( Circle radius: + radius + area: + area); radius radius area area value

C++ Spring Break Packet 11 The Java Programming Language

COMP-202 Unit 4: Programming With Iterations. CONTENTS: The while and for statements

Section 2.2 Your First Program in Java: Printing a Line of Text

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

Transcription:

CS 200 - Programming I: Programming Process Marc Renault Department of Computer Sciences University of Wisconsin Madison Spring 2019 TopHat Sec 3 (AM) Join Code: 560900 TopHat Sec 4 (PM) Join Code: 751425

Computational Thinking

1/20 Problem Solving Art of Programming Abstraction Can you see the essential parts of the problem? What are the outputs? inputs? their relationship? Can you summerize the problem at a high level? What are the different components of the solution?

1/20 Problem Solving Art of Programming Abstraction Can you see the essential parts of the problem? What are the outputs? inputs? their relationship? Can you summerize the problem at a high level? What are the different components of the solution? Computational Thinking Think like a computer. What is the sequence of actions need to accomplish the task? Start with pseudocode.

2/20 Thinking Like a Computer Programming is like Designing a Recipe

Computational Thinking Explaining and Tracing Edit-Compile-Run Cycle Java Initiation Computer Thinking Like a Computer Programming is like Designing a Recipe Human Thinking 2/20

Computational Thinking Explaining and Tracing Edit-Compile-Run Cycle Java Initiation Computer Thinking Like a Computer Programming is like Designing a Recipe Computer Thinking 2/20

Computational Thinking Explaining and Tracing Edit-Compile-Run Cycle Java Initiation Computer Thinking Like a Computer Programming is like Designing a Recipe Computer Thinking 2/20

Computational Thinking Explaining and Tracing Edit-Compile-Run Cycle Java Initiation Computer Thinking Like a Computer Programming is like Designing a Recipe Computer Thinking 2/20

3/20 Exercise Calculating the area and circumference of a circle. 1 What are the inputs? outputs? their relationship? 2 Pseudocode it! 3 Code it!

Explaining and Tracing

4/20 Explaining vs Tracing Explaining Summerize and provide a high-level explanation of what the code does in plain English.

5/20 TopHat Q1 Explain the Circle.java code: a. Calculates the area and the circumference of a circle. b. Reads a radius as input from the user and outputs the the area and the circumference of the corresponding circle. c. Creates a double variable called rad. Initializes it as 0. Prompts the user for a radius and stores it in rad. Outputs Area: ; calculates the area of a circle of radius rad and outputs it. Outputs Circumference: ; calculates the circumference of a circle of radius rad and outputs it.

6/20 Explaining vs Tracing Explaining Summerize and provide a high-level explanation of what the code does in plain English. Tracing Run the code as computer does. Put pen to paper. Write down the active variables and their values. Update them as they change as you mentally walk through the statements sequentially.

7/20 Tool for Tracing Java Visualizer https://cscircles.cemc.uwaterloo.ca/java_visualize/

Edit-Compile-Run Cycle

8/20 Edit Writing some source code (set of instructions) in plain text. Editors Text Editors: vi

8/20 Edit Writing some source code (set of instructions) in plain text. Editors Text Editors: vi Integrated Development Environment (IDE):

9/20 Compile Build your code so that it can be run on a computer. Often compilers build an executable that can be run natively on the target platform.

9/20 Compile Build your code so that it can be run on a computer. Often compilers build an executable that can be run natively on the target platform. javac The Java compiler javac produces a bytecode file that needs to be run in a virtual machine.

9/20 Compile Build your code so that it can be run on a computer. Often compilers build an executable that can be run natively on the target platform. javac The Java compiler javac produces a bytecode file that needs to be run in a virtual machine. javac produces a bytecode file with a.class file extension.

9/20 Compile Build your code so that it can be run on a computer. Often compilers build an executable that can be run natively on the target platform. javac The Java compiler javac produces a bytecode file that needs to be run in a virtual machine. javac produces a bytecode file with a.class file extension. Example: javac Circle.java produces a Circle.class bytecode file.

10/20 Run Run or execute your code. java The.class bytecode file produced by javac needs to be run in the Java virtual machine.

10/20 Run Run or execute your code. java The.class bytecode file produced by javac needs to be run in the Java virtual machine. Example: java Circle runs the Circle file.

11/20 Virtual Machine The Classic Model: Native executable Source Code Compilation Machine Code (executable) The Java Model: Virtual Machine Source Code Compilation javac foo.java Bytecode foo.class Execution java foo Virtual Machine

12/20 TopHat Q2 I have just written some Java code in a file SomeCode.java. How do I compile and run it? a. java SomeCode b. javac SomeCode.class c. javac SomeCode.java d. java SomeCode.java e. javac SomeCode f. java SomeCode.class

Java Initiation

13/20 Basic Output String Literals Double quotes ("): "I am a string literal"

13/20 Basic Output String Literals Double quotes ("): "I am a string literal" Concatenation (+): int a = 10; System.out.println("A " + a);

13/20 Basic Output String Literals Double quotes ("): "I am a string literal" Concatenation (+): int a = 10; System.out.println("A " + a); Newline escape character(\n): "First line\nsecond line"

13/20 Basic Output String Literals Double quotes ("): "I am a string literal" Concatenation (+): int a = 10; System.out.println("A " + a); Newline escape character(\n): "First line\nsecond line" Printing to the Console Print a string: System.out.print("Does not append a new line"); Print a string with a newline: System.out.println("Appends a new line");

14/20 TopHat Q3 What is the output of: System.out.println("5 and 5 = " + 5 + 5); Type the output.

15/20 Basic Input Using the Scanner Include the library at the top of the file: import java.util.scanner; Create an instance of a Scanner object: Scanner sc = new Scanner(System.in); Reading an integer: int anint = sc.nextint();

16/20 Comments and Whitespace Comments Ignored by the compiler. Written by the programmer to explain the code. Single-line (//) // Single line comment Multi-line (/* */) /** * Multi-line comment */

16/20 Comments and Whitespace Comments Ignored by the compiler. Written by the programmer to explain the code. Single-line (//) // Single line comment Multi-line (/* */) /** * Multi-line comment */ Whitespace Mostly ignored by the compiler. Good use of white space makes code easier read!

17/20 Compiler Errors and Warnings Compilation Errors Prevents compilation Syntax errors

17/20 Compiler Errors and Warnings Compilation Errors Prevents compilation Syntax errors Examples: missing ; typo (variable name, keyword) missing braces

17/20 Compiler Errors and Warnings Compilation Errors Prevents compilation Syntax errors Examples: missing ; typo (variable name, keyword) missing braces Warnings Warnings don t stop the compilation process.

17/20 Compiler Errors and Warnings Compilation Errors Prevents compilation Syntax errors Examples: missing ; typo (variable name, keyword) missing braces Warnings Warnings don t stop the compilation process. Good practice to write programs that compile without warnings.

17/20 Compiler Errors and Warnings Compilation Errors Prevents compilation Syntax errors Examples: missing ; typo (variable name, keyword) missing braces Warnings Warnings don t stop the compilation process. Good practice to write programs that compile without warnings. For even stricter compilation, use -Xlint: javac -Xlint Foo.java

Computer

18/20 Basic Machine Architecture This is a computer. von Neumann Architecture von Neumann proposed this architecture in 1945. Consists of: a processing unit, memory, input devices, and output devices.

18/20 Basic Machine Architecture John von Neumann von Neumann Architecture von Neumann proposed this architecture in 1945. Consists of: a processing unit, memory, input devices, and output devices.

19/20 Basic View of a Computer Input Device Processor Output Device Memory

20/20 Further Reading COMP SCI 200: Programming I zybooks.com, 2015. zybook code: WISCCOMPSCI200Spring2019 Chapter 1. Programming Process

Appendix References Appendix

Appendix References References

Appendix References Image Sources I http://www.eclipse.org/ https: //www.gnu.org/software/emacs/emacs.html http://packerville.blogspot.ca/2010/05/ gentlemen-this-is-football.html https: //en.wikipedia.org/wiki/microsoft_notepad http://2dvocabularynetwokr78.blogspot.fr/ 21/20

22/20 Appendix References Image Sources II http://www.lanl.gov/history/atomicbomb/ images/neumannl.gif https://brand.wisc.edu/web/logos/ https://commons.wikimedia.org/w/index.php? curid=1228427 https://commons. wikimedia.org/w/index.php?curid=57649239 http://www.zybooks.com/