STARTUP DIVKOM DAY 2 IPUNG HAVIDZ WIDJAJA / 18112023.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Java Planning our Programs Flowcharts Arithmetic Operators.
Games and Simulations O-O Programming in Java The Walker School
10-Jun-15 Introduction to Primitives. 2 Overview Today we will discuss: The eight primitive types, especially int and double Declaring the types of variables.
Primitive Data Types and Operations. Introducing Programming with an Example public class ComputeArea { /** Main method */ public static void main(String[]
Introduction to Computers and Programming Midterm Review Sana Odeh.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 6, 2005.
Introduction to Primitives. Overview Today we will discuss: –The eight primitive types, especially int and double –Declaring the types of variables –Operations.
Logical Operators Java provides two binary logical operators (&& and ||) that are used to combine boolean expressions. Java also provides one unary (!)
1 CS 177 Week 15 Recitation Slides Review. Announcements Final Exam on Sat. May 8th  PHY 112 from 8-10 AM Complete your online review of your classes.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
COMP1170 Midterm Preparation (March 17 th 2009) Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education.
Chapter 2: Algorithm Discovery and Design
An Introduction to C Programming Geb Thomas. Learning Objectives Learn how to write and compile a C program Learn what C libraries are Understand the.
Chapter 5 Conditionals and Loops. © 2004 Pearson Addison-Wesley. All rights reserved2/33 Conditionals and Loops Now we will examine programming statements.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 5: Control Structures II (Repetition)
CIS3931 – Intro to JAVA Lecture Note Set 3 19-May-05.
Intro to Java Programming  A computer follows the instruction precisely and exactly.  Anything has to be declared and defined before it can be used.
Hello AP Computer Science!. What are some of the things that you have used computers for?
Chapter 5: Control Structures II (Repetition)
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
ECS 10 10/8. Outline Announcements Homework 2 questions Boolean expressions If/else statements State variables and avoiding sys.exit(…) Example: Coin.
C Programming Tutorial – Part I CS Introduction to Operating Systems.
Introduction to Computer Systems and the Java Programming Language.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Making Decisions Chapter 5.  Thus far we have created classes and performed basic mathematical operations  Consider our ComputeArea.java program to.
Elements of a Java Program Bina Ramamurthy SUNY at Buffalo.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Chapter 4: Control Structures II
C++ Lecture 1 Friday, 4 July History of C++ l Built on top of C l C was developed in early 70s from B and BCPL l Object oriented programming paradigm.
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
Introduction Chapter 1 8/31 & 9/1 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
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.
Quiz 3 is due Friday September 18 th Lab 6 is going to be lab practical hursSept_10/exampleLabFinal/
C++ / G4MICE Course Session 1 - Introduction Edit text files in a UNIX environment. Use the g++ compiler to compile a single C++ file. Understand the C++
Object Oriented Programming (OOP) LAB # 1 TA. Maram & TA. Mubaraka TA. Kholood & TA. Aamal.
CSCI 1226 FALL 2015 MIDTERM #1 REVIEWS.  Types of computers:  Personal computers  Embedded systems  Servers  Hardware:  I/O devices: mice, keyboards,
1 Program Development  The creation of software involves four basic activities: establishing the requirements creating a design implementing the code.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 5: Control Structures II (Repetition)
Lecture 15: Course Review BJ Furman ME 30 16MAY2011.
REPETITION MTS3033 OBJECT ORIENTED PROGRAMMING 1.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Chapter 2: Fundamental Programming Structures in Java Adapted from MIT AITI Slides Control Structures.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
Jeopardy $100 VariablesErrorsLoops Classes and Objects Program Structure $200 $300 $400 $500 $400 $300 $200 $100 $500 $400 $300 $200 $100 $500 $400 $300.
IST 210: PHP LOGIC IST 210: Organization of Data IST210 1.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Object-Oriented Programming and Problem Solving Dr. Ramzi Saifan Introduction and basics of Java Slides adapted from Steven Roehrig.
Comp1004: Introduction III Java. Content How Java Works: The JVM Writing a Class in Java – Class – Member Variables – Method – Statement Magic incantations.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Control Structures- Decisions. Smart Computers Computer programs can be written to make computers seem smart Making computers smart is based on decision.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. 4 Simple Flow of Control.
Foundations of Programming: Java
Chapter 9 Repetition.
Primitive Data, Variables, Loops (Maybe)
Chapter 5 Repetition.
CET 3640 – Lecture 2 Java Syntax Chapters 2, 4, 5
Chapter 9 Control Structures.
Fundamental OOP Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Java Statements B.Ramamurthy CS114A, CS504 4/23/2019 BR.
In this class, we will cover:
Introduction to Computer Science
Review of Previous Lesson
Conditionals and Loops
Presentation transcript:

STARTUP DIVKOM DAY 2 IPUNG HAVIDZ WIDJAJA /

PROGRAMMING Welcome to day 2 startup divkom 2014 Today we will learn about programming We will focus on java programming

WHY JAVA? There are several reasons why we only focus on java programming :  1. most of programming method now focus on object oriented programming (OOP)  2. Most of Divkom’s project in programming is about developing android program  3. Java will be the foundational structure of all Android app/game development that we will cover (at least in the predictable future)

“WHAT THE….WHAT IS OOP?” A method of programming based on a hierarchy of classes, and well-defined and cooperating objects. KEY POINTS : State and Behavior Imagine an object. This can be anything, such as a dog, a bag, a bottle, a car, or any other conceivable (or sometimes inconceivable!) THING. Think about what each dog, or each bag, or each bottle, or each car has in common. They can DO things, and they can also have special quirks to them. Dogs bark, chase cats, scratch themselves, and sleep. They can be timid, quiet, loud, excitable, of any number of colors, big, small. Cars can move, can stop, can contain passengers, can go fast, or slow. Object oriented programming is a way to describe what a thing IS and what it can DO.

“SO, WHY DO WE USE OOP?” The process of designing and programming objects seems very cumbersome, why bother? It’s difficult to see from such a small example, but for larger projects, OOP techniques allow a great deal of flexibility. OOP will make your work EASIER!

“THEN, HOW DO WE OOP?”

JOB TO DO 1. prepare your android developer tools (ADT) Bundle  eclipse 2. file  new  java project (give a proper name on your project] 3. expand your project. On src, right click and choose new  Classes 4. name your class file. For example : HelloWorld

Result :

ABOUT JAVA SYNTAX A. Variables in java  Example : integer, Boolean, float, string, char, etc…  Variables may be a global/local variables (what’s the difference?]  Global : You can use it in any method/class on your java project  Local : you can only use it in specific method/class

MORE ABOUT VARIABLES….. 1. Instance variable  Declared without ‘static’  example : int number  Has unique values depending on each instance that they belong to 2. Class variable  Declared with ‘static’  example : static int number = 10  There will be a single copy of this variable

LET’S TRY THIS! Result :

ANALYZING THE SYNTAX…. 1. the first result will be 11 because total is the value of class/global variable ‘eight’ is added to local variable ‘number’, which means 8+3 = the second result will be 16 because total is the value of class/global variable ‘eight’ s added to class/global variable ‘number’, which means 8+8 = 16.

B. Basic operation  There are several basic math operations on java :  + : addition  - : Substraction  / : Division  * : Multiplication  % : mod operation (returns the value of remainder]

LET’S TRY THIS! (2) Result :

C. Increment and Decrement  Another math operation in java is increment and decrement :  1. increment : increase the value of a variable with a specific value  2. decrement : decrease the value of a variable with a specific value  For example in java syntax  counter++ (adds one to counter variable], counter+=3 [adds 3 to counter variable]  If there is an exact value before increment/decrement, the previous value will be added/substracted.

MORE ABOUT INCREMENT/DECREMENT There are two types of increment/decrement in java syntax :  1. Pre-increment/decrement : the value is added/substracted first before being executed  2.Post-increment/decrement : The value is executed first before being added/substracted

LET’S TRY THIS! [3] Result:

D. conditional (if-else]  In java, there is also if-else statement, like other programming languages.  It is about comparison between two/more variables  Operator used :  ==  equals to  !=  doesn’t equal to  >=  more than equal  <=  less than equal  >  more than  <  less than  &&  logical operator ‘and’  ||  logical operator ‘or’

LET’S TRY THIS! [4] Result :

D. switch method  It’s like if-else statement, but more general  Assign an output depends on statement

Result :

E. looping techniques  There are several methods to do looping techs :  1. while-do  2. do-while  3.for

MORE ABOUT LOOPING Result : RESULT :

Result :

F. randomization  For several programs, we need randomization (for example, about number which will come from a rolled dice]  Declaration 

There will be an error before executing (OMG Hello! Why???] The answer is : you need to import a library How to import a library  CTRL+SHIFT+O

PRINTF/SCANF Remember about printf/scanf on C programming language? In java, there are several ways to express those operation We use ‘system.out.println(“ “) ‘ to print some text on monitor, as we have used before We use ‘scanner.input = new scanner(system.in)’ to scan the input from keyboard Of course we need to import a library  use CTRL+SHIFT+O This method is used for a string input, so the data type must be string How about integer input? See the next slide

Result :

TIPS AND TRICK You see that your syntax is not good enough! (read : not tidy  )  Use CTRL+SHIFT+F to make your syntax looks beautiful if you want to type your syntax faster, try CTRL+SPACE

SUMMARY You have known what oop is You have known why we use oop and java You have known about some basic java languages You have known about some basic math operations You have known about increment/decrement You have know about variables You have known about conditional (if-else), switch-case You have known about looping techniques You have known about randomization You have known about printing and scanning Several tips and tricks given

ANY QUESTION?

HOMEWORKS! “omg hello why homeworks??” Practice makes perfect Your homeworks (individually, choose one only )

YOUR HOMEWORKS 1. ‘Equal Game!’  Create a simple equal game that is played by 2 players (You and Computer). This game is adopted from ‘Cepe’ Game in Indonesia, but much different. How this work? The specification below will explain all of this :  First, a number shown from a random process. For example, the first number shown is 4. It is the initial total.  You will be the first player to draw a card also from a random process. It is represented as number.  You will be given a decision whether you want to add/substract your number to/from the first number shown. Now the total depends on your decision.  Computer will draw a card from a random process (represented as number too). The opponent will add/substract depends on total. In this case, if total <= 45, computer will always add the number. Now, the total is changed (added/substracted by computer’s choice)  If the total is 50 after you add your number, you win.  If the total is 50 after opponent adds his number, you lose.  The total may be less/more than 50  If the total is negative, the game ends immediately.

2. Too hard? You can submit your own PROGRAM!  The specification is : you need to use all of the basic syntax in Java you have learnt today.  The program must at least use 2 procedures/function to be called in main program Create the program effectively and efficiently! Submit your program to : dengan subject : Tugas2_Nama_NIM Deadline : Saturday, November (11.59 PM) File to be sent : java format file. (xxx.java) or the whole package you’ve made!

THANK YOU FOR YOUR ATTENTION!