Week 1 - Friday COMP 1600.

Slides:



Advertisements
Similar presentations
Programming for Beginners
Advertisements

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Lecture 0 CSIS10A Overview. Welcome to CSIS10A (5 mins) – Typical format for class meetings New material first (monitors off, notebooks out) Practice.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. OBJECTIVES FOR THIS UNIT Upon completion of this unit, you should be able to: Explain the Java virtual machine.
Chapter 2: Your First Program! Hello World: Let’s Program  All programs must have the extension.java  Our first program will be named: HelloWorld.java.
Week 1 - Wednesday.  What did we talk about last time?  Syllabus  Computers.
Week 2: Primitive Data Types 1.  Programming in Java  Everything goes inside a class  The main() method is the starting point for executing instructions.
1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
Programming. Software is made by programmers Computers need all kinds of software, from operating systems to applications People learn how to tell the.
1 Chapter-01 Introduction to Computers and C++ Programming.
Introducing Java.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
COMP 110: Introduction to Programming Tyler Johnson January 14, 2009 MWF 11:00AM-12:15PM Sitterson 014.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Week 2 - Monday.  What did we talk about last time?  Software development  Lab 1.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Python From the book “Think Python”
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
CS 177 Recitation Week 1 – Intro to Java. Questions?
ITP 109 Week 2 Trina Gregory Introduction to Java.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Week 3 - Monday.  What did we talk about last time?  Video games  Lab 2.
CIS 234: Object-Oriented Programming with Java
INTRODUCTION TO ROBOTICS Part 5: Programming
Week 1 - Wednesday CS 121.
Installing Java on a Home machine
Lecture 1b- Introduction
Week 2 - Wednesday CS 121.
Development Environment
Week 4 - Friday CS 121.
Topics Designing a Program Input, Processing, and Output
COSC 1306 COMPUTER SCIENCE AND PROGRAMMING
Week 3 - Monday CS 113.
Programming Language Hierarchy, Phases of a Java Program
CSCI-235 Micro-Computer Applications
Week 3 - Friday CS222.
Formatting Output.
A451 Theory – 7 Programming 7A, B - Algorithms.
Installing Java on a Home machine
Chapter 1 Coding Introduction.
Chapter 11 Introduction to Programming in C
Introduction to C++ Programming
Chapter 1: Computer Systems
Fundamentals of Programming
Chapter 11 Introduction to Programming in C
Programming Basics - RobotC
CMP 131 Introduction to Computer Programming
Programming.
Programming Fundamentals Lecture #3 Overview of Computer Programming
Topics Designing a Program Input, Processing, and Output
Welcome to AP Computer Science A!
Tonga Institute of Higher Education IT 141: Information Systems
Topics Designing a Program Input, Processing, and Output
Tonga Institute of Higher Education IT 141: Information Systems
Computer Programming-1 CSC 111
Programming language translators
Presentation transcript:

Week 1 - Friday COMP 1600

Last time What did we talk about last time? Finished discussing hardware Our first Java program

Project 1

Questions?

More Java Syntax

Semicolons In Java, like C, C++, and many other languages, we separate different statements with a semicolon ( ; ) If we want to do a number of statements, we just type them in order, with a semicolon after each one

Sequencing For example, instead of one print statement, we can have several: Each statement is an instruction to the computer They are printed in order, one by one System.out.println("Hello, world!"); System.out.println("Hello, galaxy!"); System.out.println("Goodbye, world!");

Case Sensitivity Java is a case sensitive language Class is not the same as class System.out.println("Word!"); prints correctly system.Out.Println("Word!"); does not compile

Whitespace Java generally ignores whitespace (tabs, newlines, and spaces) is the same as: You should use whitespace effectively to make your code readable System.out.println("Hello, world!"); System.out. println( "Hello, world!");

Comments Programs can be confusing Sometimes you want to leave notes for yourself or anyone else who is reading your code The standard way to do this is by using comments Although comments appear in the code, they do not affect the final program

Comments There are two kinds of comments (actually 3) Single line comments use // Multi-line comments start with a /* and end with a */ System.out.println("Hi!"); // this is a comment System.out.println("Hi!"); /* this is a multi-line comment */

What we know Java is a large, complex language Even so, there are only a few tasks that you can ask it to do You have already learned: Sequencing Basic output

Where we are headed There are not that many other things you can tell Java to do Storing numbers and text Basic mathematical operations Choosing between several options Doing a task repetitively Storing lists of things More complicated input and output Naming a task so that you can use it over and over again That's basically it

Software Development

What is programming again? The process of giving computers very detailed instructions about what to do How do we do that exactly? First, we need a programming language like Java How do we turn a set of instructions written so that a human can read them into a set of instructions that a computer can read? Magic, of course!

First, let's talk about languages There are many different programming languages: Java C/C++ ML …thousands more Each has different advantages in different situations

High vs. low We can classify languages as high or low level High level languages allow you to give more abstract commands that are more like human thought processes or mathematics Low level languages are closer to the computer world and give explicit instructions for the hardware to follow Python Java C++ C Assembly Language Machine Code Low High

Compilers We use a program called a compiler to turn a high level language into a low level language Usually, the low level language is machine code With Java it's a little more complex

How does that work in general? Computer! Solve a problem; Compile 010101010 010100101 001110010 Execute Source Code Machine Code Hardware

What's the issue with Java? Java is more complicated Java runs on a virtual machine, called the JVM Java is compiled to an intermediate stage called bytecode, which is platform independent Then, the JVM runs a just-in-time compiler whenever you run a Java program, to turn the bytecode into platform dependent machine code

Compilation and execution for Java class A { Problem p; p.solve(); } Compile 101110101 101011010 110010011 JVM 010101010 010100101 001110010 Execute Java Source Code Java Bytecode Machine Code Hardware Platform Independent Platform Dependent

Let's review the steps we'll use Write a program in Java Compile the program into bytecode Run the bytecode using the JVM (which automatically compiles the bytecode to machine code)

Software development Often goes through phases similar to the following: Understand the problem Plan a solution to the problem Implement the solution in a programming language Test the solution Maintain the solution and do bug fixes Factor of 10 rule!

Data Representation

Binary Hardware You have heard people talking about all the 1's and 0's inside of a computer What does that all really mean? Using semiconductor physics, we can make a tiny little piece of a microchip be in one of two states, say, OFF and ON, like a switch If we say that OFF is 0 and ON is 1, then, by using a lot of these switches, we can represent a lot of 1's and 0's

Binary Representation What do we do with those 1's and 0's? To begin with, we represent numbers How many of you have heard of base 10? How many of you have heard of base 2? What's the definition of a number system with a given base?

Base 10 (decimal) numbers Our normal number system is base 10 This means that our digits are: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 Base 10 means that you need 2 digits to represent ten, namely 1 and 0 Each place in the number as you move left corresponds to an increase by a factor of 10

3,482,931 Base 10 Example Ten thousands Hundreds Millions Ones Hundred Tens

Base 2 (binary) numbers The binary number system is base 2 This means that its digits are: 0 and 1 Base 2 means that you need 2 digits to represent two, namely 1 and 0 Each place in the number as you move left corresponds to an increase by a factor of 2 instead of 10

11111100011 Base 2 Example Sixty fours 256's Sixteens Fours 1024's Ones 512's 128's Thirty twos Eights Twos

So, what's the value? 11111100011 = 1∙210 + 1∙29 + 1∙28 + 1∙27 + 1∙26 + + 1∙25 + 0∙24 + 0∙23 + 0∙22 + 1∙21 + 1∙20 = 1024 + 512 + 256 + 128 + 64 + 32 + 2 + 1 = 2019

The good news You don't actually have to worry about doing binary conversions when you are coding Java You should know this information because it explains how Java is different from math In math, you can talk about an arbitrarily large number In Java, each number is stored with a specific number of binary digits There are limits on how big (or small) a given number can be

Upcoming

Next time… We'll talk more about data representation

Reminders Read Chapter 3 No class on Monday! No lab assignment on Tuesday, but you can come to ask questions or get started on Project 1 Interested in coaching 7-18 year old kids in programming? Consider working at theCoderSchool For more information: Visit https://www.thecoderschool.com/locations/westerville/ Contact Kevin Choo at kevin@thecoderschool.com Ask me!