JAVA pagrindai Lek. Liudas Drejeris

Size: px
Start display at page:

Download "JAVA pagrindai Lek. Liudas Drejeris"

Transcription

1 JAVA pagrindai Lek. Liudas Drejeris

2 Programa (1) Programa, tai eilė instrukcijų (vadinamų programiniais sakiniais), kurie vykdomi paeiliui, kol gaunamas norimas rezultatas.

3 Programa (2)

4 Programa (2)

5 /* * Print the area and circumference of a circle, given its radius. */ public class CircleComputation { // Saved as "CircleComputation.java" Programa (3) public static void main(string[] args) { // Declare variables double radius, area, circumference; final double PI = ; // Assign a value to radius radius = 1.2; // Compute area and circumference area = radius * radius * PI; circumference = 2.0 * radius * PI; // Print results System.out.print("The radius is "); // Print description System.out.println(radius); // Print the value stored in the variable } }

6 Komentarai Sakiniai Blokai Kodo sintaksė

7 Komentarai (1) Vienos eilutės komentarai /*... */ //... Kelių eilučių komentaras /*... *... */

8 Komentarai (2) /* * Keliu eiluciu komentaras */ public class Hello { // Vienos eilutės komentaras public static void main(string[] args) { System.out.println("Hello, world!"); // Vienos eilutės komentaras } }

9 Kodo sakiniai (1) Sakinys dažniausiai prasideda iš naujos eilutės. Visada pasibaigia kabliataškiu ;. Pažymį vieną kode atliekamą veiksmą.

10 Kodo sakiniai (2) int number1 = 11; int number2 = 22; int number3 = 33; int sum; sum = number1 + number2 + number3; System.out.println(sum);

11 Kodo blokai (1) Kodo blokai prasideda atidaromuoju skliausteliu {. Baigiasi uždaromuoju skliausteliu }. Jie dažniausiai pažymi didesnę kodo dalį, kurios sakiniai susiję tarpusavyje. Kodo bloko pabaigoje (po uždaromojo skliaustelio) kabliataškis nededamas.

12 Kodo blokai (2) public static void main(string[] args) { } System.out.println("Hello, world!");

13 Kodo blokai (3) public class PrintTest { public static void main(string[] args) { System.out.println("Hello, world!"); } }

14 Pagrindiniai programavimo elementai Kintamieji Operacijos Ciklai Sąlygos Lyginamosios operacijos Kintamojo tipo keitimas

15 Kintamieji (1) Kintamasis turinti vardą atminties dalis, kurioje saugoma nurodyta informacija. Kintamasis turi tipą, vardą ir reikšmę. Tipas nurodo kaip saugoma, vardas kur saugoma, reikšmė kas saugoma.

16 Kintamieji (2)

17 Kintamieji (3) vartype varname; vartype varname1, varname2,...; vartype varname = initialvalue; vartype varname1 = initialvalue1, varname2 = initialvalue2,... ;

18 Kintamieji (4) int sum; int number1, number2; int height = 20; string name = vardas, surname= pavarde ;

19 Kintamieji (5) int sveikas skaičius. double skaičius su kableliu. char vienas simbolis. string teksto eilutė. boolean loginis kintamasis (true/false)

20 Operacijos (1) Operatorius Reikšmė Pavyzdys + Sudėtis x + y - Atimtis x - y * Daugyba x * y / Dalyba x / y % Dalybos liekana x % y ++ Padidinti per 1 x++ arba y++ -- Sumažinti per 1 x-- arba y--

21 Operacijos (2) int number1 = 98; int number2 = 5; int sum, difference, product, quotient, remainder; sum = number1 + number2; difference = number1 - number2; product = number1 * number2; quotient = number1 / number2; remainder = number1 % number2;

22 Ciklai (1)

23 while ciklas for ciklas foreach ciklas Ciklai (2)

24 Ciklai (3) paruošiamasis sakinys; while (salyga) { kartojamas kodo blokas; } kitas kodo sakinys;

25 Ciklai (4) int number = 0; int sum = 0; while (number <= 3) { sum = sum + number; number++; } System.out.println(sum);

26 Ciklai (5) for (paruošiamasis sakinys; sąlyga; pakeitimas) { kartojamas kodo blokas; } kitas kodo sakinys;

27 Ciklai (6) int sum = 0; for (int number = 0; number <= 3; number++) { sum = sum + number; } System.out.println(sum);

28 Sąlygos (1)

29 Sąlygos (2) if ( bandoma sąlyga ) { } kodo blokas;

30 Sąlygos (2) if ( a > b ) { } c = a - b;

31 Sąlygos (3)

32 Sąlygos (4) if ( bandoma sąlyga ) { kodo blokas; } else { kodo blokas; }

33 Sąlygos (4) if ( a > b ) { c = a - b; } else { c = b - a; }

34 Sąlygos (5) if ( a > b ) { c = a - b; } else if ( a == b ) { c = b + a; } else { c = b - a; }

35 switch(kintamasis) { case reiksme: kodo sakinys 1; break; case reiksme: kodo sakinys 2; break;. } Sąlygos (6)

36 Lyginamosios operacijos (1) Operatorius Reikšmė Pavyzdys == Lygu x == y!= Nelygu x!= y > Daugiau x > y >= Daugiau arba lygu x >= y < Mažiau x < y <= Mažiau arba lygu x <= y

37 Lyginamosios operacijos (2) Operatorius Reikšmė Pavyzdys && Ir (x > 1) && (x < 100) Arba (x < 1) (x > 100)! Ne!(x == 10)

38 Kintamojo tipo keitimas int number = 5; string text; text = (string) number;

39 Objektinis programavimas Metodai Klasės Objektai Klasių paveldimumas

PHP PROGRAMOS EIGOS VYKDYMO VALDYMAS

PHP PROGRAMOS EIGOS VYKDYMO VALDYMAS PHP PROGRAMOS EIGOS VYKDYMO VALDYMAS Sąlygos sakiniai PHP skriptų vykdymo eigą galite valdyti naudodami sąlygos sakinius. Sąlygos sakiniai tai loginės struktūros, kuriose saugomas kodas, įvykdomas įgyvendinus

More information

C programavimo kalba. 3 paskaita (Sąlygos ir ciklo operatoriai, funkcija scanf() )

C programavimo kalba. 3 paskaita (Sąlygos ir ciklo operatoriai, funkcija scanf() ) C programavimo kalba 3 paskaita (Sąlygos ir ciklo operatoriai, funkcija scanf() ) Sąlygos operatorius if - else Sąlygos operatoriai skirti perduoti programos vykdymą vienai ar kitai programos šakai. Operatorius

More information

C++ programavimo kalba

C++ programavimo kalba C++ programavimo kalba Operatorių perkrovimas (7 paskaita) Operatorių perdengimas Programavimo kalbose naudojami operatoriai pasižymi polimorfizmu (daugiavariantiškumu). Kaip pavyzdys gali būti operatorius

More information

Review. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char

Review. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char Review Primitive Data Types & Variables int, long float, double boolean char String Mathematical operators: + - * / % Comparison: < > = == 1 1.3 Conditionals and Loops Introduction to Programming in

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 05 / 31 / 2017 Instructor: Michael Eckmann Today s Topics Questions / Comments? recap and some more details about variables, and if / else statements do lab work

More information

Polimorfizmas. Lekt. dr. Pijus Kasparaitis m. m. pavasario semestras.

Polimorfizmas. Lekt. dr. Pijus Kasparaitis m. m. pavasario semestras. Polimorfizmas Lekt. dr. Pijus Kasparaitis pkasparaitis@yahoo.com 2009-2010 m. m. pavasario semestras Dar apie paveldėjimą Java kalboje kiekvienas paveldėtos klasės objektas gali būti naudojamas ten, kur

More information

Parengė ITMM Artūras Šakalys 1

Parengė ITMM Artūras Šakalys 1 2014.02.02 Parengė ITMM Artūras Šakalys 1 2014.02.02 Parengė ITMM Artūras Šakalys 2 Kaip suprantame masyvą? Pavyzdys: Peteliškių šeima; Gėlių laukas; 2014.02.02 Parengė ITMM Artūras Šakalys 3 Kaip suprasti

More information

Getting started with Java

Getting started with Java Getting started with Java by Vlad Costel Ungureanu for Learn Stuff Programming Languages A programming language is a formal constructed language designed to communicate instructions to a machine, particularly

More information

Lec 3. Compilers, Debugging, Hello World, and Variables

Lec 3. Compilers, Debugging, Hello World, and Variables Lec 3 Compilers, Debugging, Hello World, and Variables Announcements First book reading due tonight at midnight Complete 80% of all activities to get 100% HW1 due Saturday at midnight Lab hours posted

More information

C++ programavimo kalba. Konstruktorius, destruktorius, klasių metodų modifikatoriai, objektų masyvai (4 paskaita)

C++ programavimo kalba. Konstruktorius, destruktorius, klasių metodų modifikatoriai, objektų masyvai (4 paskaita) C++ programavimo kalba Konstruktorius, destruktorius, klasių metodų modifikatoriai, objektų masyvai (4 paskaita) Konstruktorius Sukuriant objektą, jo duomenims paprastai turi būti priskiriamos pradinės

More information

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable? Peer Instruction 8 Classes and Objects How can multiple methods within a Java class read and write the same variable? A. Allow one method to reference a local variable of the other B. Declare a variable

More information

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution Ch 5 Arrays Multiple Choice 01. An array is a (A) (B) (C) (D) data structure with one, or more, elements of the same type. data structure with LIFO access. data structure, which allows transfer between

More information

Java Simple Data Types

Java Simple Data Types Intro to Java Unit 1 Multiple Choice Test Key Java Simple Data Types This Test Is a KEY DO NOT WRITE ON THIS TEST This test includes program segments, which are not complete programs. Answer such questions

More information

C++ programavimo kalba

C++ programavimo kalba C++ programavimo kalba Rodyklė this, C++ string klasė (9 paskaita) Rodyklėthis Visos objekto funkcijos gali naudotis rodykle this, kuri rodo į patį objektą. Tokiu būdu kiekviena funkcija gali rasti objekto,

More information

JAVA Ch. 4. Variables and Constants Lawrenceville Press

JAVA Ch. 4. Variables and Constants Lawrenceville Press JAVA Ch. 4 Variables and Constants Slide 1 Slide 2 Warm up/introduction int A = 13; int B = 23; int C; C = A+B; System.out.print( The answer is +C); Slide 3 Declaring and using variables Slide 4 Declaring

More information

K R I S T I N A L A P I N. I dalis. Matematikos ir statistikos studijų krypčių pirmo kurso studentams

K R I S T I N A L A P I N. I dalis. Matematikos ir statistikos studijų krypčių pirmo kurso studentams V I L N I A U S U N I V E R S I T E T AS M A T E M A T I K O S I R I N F O R M A T I K O S F A K U L T E T A S P R O G R A M Ų S I S T E M Ų K A T E D R A K R I S T I N A L A P I N Programavimas C I dalis

More information

KAUNO TECHNOLOGIJOS UNIVERSITETAS

KAUNO TECHNOLOGIJOS UNIVERSITETAS KAUNO TECHNOLOGIJOS UNIVERSITETAS INFORMATIKOS FAKULTETAS VALDIKLIŲ PROGRAMAVIMAS STANDARTO IEC 61131-3 KALBOMIS Referatas Atliko: Kęstutis Valinčius Kaunas 2011 Turinys 1 Įvadas... 3 2 Struktūriniai elementai...

More information

COMP-202: Foundations of Programming

COMP-202: Foundations of Programming COMP-202: Foundations of Programming Lecture 3: Basic data types Jackie Cheung, Winter 2016 Review: Hello World public class HelloWorld { } public static void main(string[] args) { } System.out.println("Hello,

More information

Section 003 Fall CS 170 Exam 1. Name (print): Instructions:

Section 003 Fall CS 170 Exam 1. Name (print): Instructions: CS 170 Exam 1 Section 003 Fall 2012 Name (print): Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than

More information

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution Ch 5 Arrays Multiple Choice Test 01. An array is a ** (A) data structure with one, or more, elements of the same type. (B) data structure with LIFO access. (C) data structure, which allows transfer between

More information

Struktūrų sintaksė Struktūra tai vienodo arba skirtingo tipo kintamųjų rinkinys. Sintaksė: struct vardas { ; type1 var1; type2 var2;... typen varn; //

Struktūrų sintaksė Struktūra tai vienodo arba skirtingo tipo kintamųjų rinkinys. Sintaksė: struct vardas { ; type1 var1; type2 var2;... typen varn; // C programavimo kalba 10 paskaita (Struktūros) Struktūrų sintaksė Struktūra tai vienodo arba skirtingo tipo kintamųjų rinkinys. Sintaksė: struct vardas { ; type1 var1; type2 var2;... typen varn; // Gale

More information

ITERATION WEEK 4: EXMAPLES IN CLASS

ITERATION WEEK 4: EXMAPLES IN CLASS Monday Section 2 import java.util.scanner; public class W4MSection2 { ITERATION WEEK 4: EXMAPLES IN CLASS public static void main(string[] args) { Scanner input1 = new Scanner (System.in); int CircleCenterX

More information

Apletai (įskiepiai) Lekt. dr. Pijus Kasparaitis m. m. pavasario semestras.

Apletai (įskiepiai) Lekt. dr. Pijus Kasparaitis m. m. pavasario semestras. Apletai (įskiepiai) Lekt. dr. Pijus Kasparaitis pkasparaitis@yahoo.com 2008-2009 m. m. pavasario semestras Java grafinės bibliotekos AWT (Abstract Window Toolkit) Swing 2009.04.09 P.Kasparaitis. Objektinis

More information

First Programs. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington

First Programs. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington First Programs CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1 Output System.out.println( ) prints out something. System.out.println is the first

More information

Key Java Simple Data Types

Key Java Simple Data Types AP CS P w Java Unit 1 Multiple Choice Practice Key Java Simple Data Types This test includes program segments, which are not complete programs. Answer such questions with the assumption that the program

More information

Web technologijos. Hostingas JavaScript PHP

Web technologijos. Hostingas JavaScript PHP jquery & PHP Web technologijos Hostingas JavaScript PHP Kelios hostingo kompanijos serveriai.lt hostex.lt hostinger.lt Nemokamas hostingas su PHP/mysql http://mindaugas.zz.mu/jm1.html Hostingo paslaugų

More information

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette COMP 250: Java Programming I Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette Variables and types [Downey Ch 2] Variable: temporary storage location in memory.

More information

Condi(onals and Loops

Condi(onals and Loops Condi(onals and Loops 1 Review Primi(ve Data Types & Variables int, long float, double boolean char String Mathema(cal operators: + - * / % Comparison: < > = == 2 A Founda(on for Programming any program

More information

Variable initialization and assignment

Variable initialization and assignment Variable initialization and assignment int variable_name; float variable_name; double variable_name; String variable_name; boolean variable_name; Initialize integer variable Initialize floating point variable

More information

ĮVADAS JVM Java Virtual Machine Java virtualios mašinos (JVM) JVM write once, run everywhere

ĮVADAS JVM Java Virtual Machine Java virtualios mašinos (JVM) JVM write once, run everywhere ĮVADAS The Java programming language was introduced in 1995 by Sun Microsystems which has since merged into Oracle Corporation. Derived from languages such as C and C++. Pradžioje Java buvo skirta programuoti

More information

CSEN 102 Introduction to Computer Science

CSEN 102 Introduction to Computer Science CSEN 102 Introduction to Computer Science Lecture 2: Python and Sequential Algorithms Prof. Dr. Slim Abdennadher Dr. Aysha Alsafty, slim.abdennadher@guc.edu.eg, aysha.alsafty@guc.edu.eg German University

More information

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

Entry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process Entry Point of Execution: the main Method Elementary Programming EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG For now, all your programming exercises will

More information

Controls Structure for Repetition

Controls Structure for Repetition Controls Structure for Repetition So far we have looked at the if statement, a control structure that allows us to execute different pieces of code based on certain conditions. However, the true power

More information

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018 Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 1: Types and Control Flow http://courses.cs.cornell.edu/cs2110/2018su Lecture 1 Outline 2 Languages Overview Imperative

More information

CS171:Introduction to Computer Science II

CS171:Introduction to Computer Science II CS171:Introduction to Computer Science II Department of Mathematics and Computer Science Li Xiong 9/7/2012 1 Announcement Introductory/Eclipse Lab, Friday, Sep 7, 2-3pm (today) Hw1 to be assigned Monday,

More information

INFO Object-Oriented Programming

INFO Object-Oriented Programming INFO0062 - Object-Oriented Programming Exercise session #1 - Basic Java programs Jean-François Grailet University of Liège Faculty of Applied Sciences Academic Year 2017-2018 Creating a simple Java program

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming Java Syntax Program Structure Variables and basic data types. Industry standard naming conventions. Java syntax and coding conventions If Then Else Case statements Looping (for,

More information

Lecture 5: Methods CS2301

Lecture 5: Methods CS2301 Lecture 5: Methods NADA ALZAHRANI CS2301 1 Opening Problem Find the sum of integers from 1 to 10, from 20 to 30, and from 35 to 45, respectively. 2 Solution public static int sum(int i1, int i2) { int

More information

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

More Things We Can Do With It! Overview. Circle Calculations. πr 2. π = More operators and expression types More statements More Things We Can Do With It! More operators and expression types More s 11 October 2007 Ariel Shamir 1 Overview Variables and declaration More operators and expressions String type and getting input

More information

COMP-202: Foundations of Programming. Lecture 4: Methods Jackie Cheung, Winter 2016

COMP-202: Foundations of Programming. Lecture 4: Methods Jackie Cheung, Winter 2016 COMP-202: Foundations of Programming Lecture 4: Methods Jackie Cheung, Winter 2016 Announcements Quiz 1 postponed: Due Jan 26 at 11:59pm Assignment 1 postponed: Due on Feb 1 at 11:59pm 2 Review What is

More information

First Programs. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington

First Programs. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington First Programs CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1 Output System.out.println( ) prints out something. System.out.println is the first

More information

Java Simple Data Types

Java Simple Data Types Intro to Java Unit 1 Multiple Choice Java Simple Data Types DO NOT WRITE ON THIS TEST This test includes program segments, which are not complete programs. Answer such questions with the assumption that

More information

Chapter 5 Lab Methods

Chapter 5 Lab Methods Chapter 5 Lab Methods Lab Objectives Be able to write methods Be able to call methods Be able to write javadoc comments Be able to create HTML documentation using the javadoc utility Introduction Methods

More information

1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'

1. Which of the following is the correct expression of character 4? a. 4 b. 4 c. '\0004' d. '4' Practice questions: 1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4' 2. Will System.out.println((char)4) display 4? a. Yes b. No 3. The expression "Java

More information

Vilniaus universitetas Fizikos fakultetas Radiofizikos katedra R. Grigalaitis Programavimas (Programavimo C++ kalba paskaitų konspektas)

Vilniaus universitetas Fizikos fakultetas Radiofizikos katedra R. Grigalaitis Programavimas (Programavimo C++ kalba paskaitų konspektas) Vilniaus universitetas Fizikos fakultetas Radiofizikos katedra R. Grigalaitis Programavimas (Programavimo C++ kalba paskaitų konspektas) Vilnius 2010 - 2 - Turinys PROGRAMAVIMO SAMPRATA... - 4 - KINTAMIEJI

More information

Programavimas C kalba

Programavimas C kalba Programavimas C kalba Mokomoji priemonė Elektronikos specialybės studentams Vytautas Vyšniauskas 2008.01.28 09:26 Šiaulių Universitetas, 2007 Turinys Įvadas... 4 1 Simbolių kodavimas ir ASCII kodų lentelė...

More information

First Programs. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington

First Programs. CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington First Programs CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1 Output System.out.println( ) prints out something. System.out.println is the first

More information

Java Loop Control. Programming languages provide various control structures that allow for more complicated execution paths.

Java Loop Control. Programming languages provide various control structures that allow for more complicated execution paths. Loop Control There may be a situation when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed first,

More information

COMP-202. Recursion. COMP Recursion, 2011 Jörg Kienzle and others

COMP-202. Recursion. COMP Recursion, 2011 Jörg Kienzle and others COMP-202 Recursion Recursion Recursive Definitions Run-time Stacks Recursive Programming Recursion vs. Iteration Indirect Recursion Lecture Outline 2 Recursive Definitions (1) A recursive definition is

More information

1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005

1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005 1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005 Name: E-mail Address: TA: Section: You have 80 minutes to complete this exam. For coding questions, you do not need to

More information

CS 11 java track: lecture 1

CS 11 java track: lecture 1 CS 11 java track: lecture 1 Administrivia need a CS cluster account http://www.cs.caltech.edu/ cgi-bin/sysadmin/account_request.cgi need to know UNIX www.its.caltech.edu/its/facilities/labsclusters/ unix/unixtutorial.shtml

More information

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8 Today... Java basics S. Bowers 1 of 8 Java main method (cont.) In Java, main looks like this: public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Q: How

More information

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

Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #2

More information

true false Imperative Programming III, sections , 3.0, 3.9 Introductory Programming Control flow of programs While loops: generally Loops

true false Imperative Programming III, sections , 3.0, 3.9 Introductory Programming Control flow of programs While loops: generally Loops Introductory Programming Imperative Programming III, sections 3.6-3.8, 3.0, 3.9 Anne Haxthausen a IMM, DTU 1. Loops (while, do, for) (sections 3.6 3.8) 2. Overview of Java s (learnt so far) 3. Program

More information

BASIC ELEMENTS OF A COMPUTER PROGRAM

BASIC ELEMENTS OF A COMPUTER PROGRAM BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators

More information

Chapter 5: Methods. by Tony Gaddis. Starting Out with Java: From Control Structures through Objects. Fourth Edition

Chapter 5: Methods. by Tony Gaddis. Starting Out with Java: From Control Structures through Objects. Fourth Edition Chapter 5: Methods Starting Out with Java: From Control Structures through Objects Fourth Edition by Tony Gaddis Addison Wesley is an imprint of 2010 Pearson Addison-Wesley. All rights reserved. Reading

More information

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment

More information

Uždavinių sprendimas MATLAB aplinkoje

Uždavinių sprendimas MATLAB aplinkoje Operacijų tyrimas. Įvadas. Laboratoriniai darbai 1 Uždavinių sprimas MATLAB aplinkoje Matlab tai interaktyvi sistema, skirta atlikti inžinerinius bei mokslinius skaičiavimus. Sistemos aplinkoje galima

More information

Following is the general form of a typical decision making structure found in most of the programming languages:

Following is the general form of a typical decision making structure found in most of the programming languages: Decision Making Decision making structures have one or more conditions to be evaluated or tested by the program, along with a statement or statements that are to be executed if the condition is determined

More information

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a Spring 2017 Name: TUID: Page Points Score 1 28 2 18 3 12 4 12 5 15 6 15 Total: 100 Instructions The exam is closed book, closed notes. You may not use a calculator, cell phone, etc. i Some API Reminders

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading: 2.1-2.2 1 2 Data and expressions reading: 2.1 3 The computer s view Internally, computers store everything as 1 s and 0

More information

Write a program which converts all lowercase letter in a sentence to uppercase.

Write a program which converts all lowercase letter in a sentence to uppercase. Write a program which converts all lowercase letter in a sentence to uppercase. For Example: 1) Consider a sentence "welcome to Java Programming!" its uppercase conversion is " WELCOME TO JAVA PROGRAMMING!"

More information

Java Basic Programming Constructs

Java Basic Programming Constructs Java Basic Programming Constructs /* * This is your first java program. */ class HelloWorld{ public static void main(string[] args){ System.out.println( Hello World! ); A Closer Look at HelloWorld 2 This

More information

Question 2. [5 points] Given the following symbolic constant definition

Question 2. [5 points] Given the following symbolic constant definition CS 101, Spring 2012 Mar 20th Exam 2 Name: Question 1. [5 points] Determine which of the following function calls are valid for a function with the prototype: void drawrect(int width, int height); Assume

More information

Computer Programming, I. Laboratory Manual. Experiment #3. Selections

Computer Programming, I. Laboratory Manual. Experiment #3. Selections Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #3

More information

McGill University School of Computer Science COMP-202A Introduction to Computing 1

McGill University School of Computer Science COMP-202A Introduction to Computing 1 McGill University School of Computer Science COMP-202A Introduction to Computing 1 Midterm Exam Thursday, October 26, 2006, 18:00-20:00 (6:00 8:00 PM) Instructors: Mathieu Petitpas, Shah Asaduzzaman, Sherif

More information

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

Tester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time Tester vs. Controller Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG For effective illustrations, code examples will mostly be written in the form of a tester

More information

Loops. CSE 114, Computer Science 1 Stony Brook University

Loops. CSE 114, Computer Science 1 Stony Brook University Loops CSE 114, Computer Science 1 Stony Brook University http://www.cs.stonybrook.edu/~cse114 1 Motivation Suppose that you need to print a string (e.g., "Welcome to Java!") a user-defined times N: N?

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading: 2.1-2.2 1 Data and expressions reading: 2.1 self-check: 1-4 videos: Ch. 2 #1 2 Data types type: A category or set of data

More information

Elementary Programming

Elementary Programming Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG Learning Outcomes Learn ingredients of elementary programming: data types [numbers, characters, strings] literal

More information

CS 177 Week 15 Recitation Slides. Review

CS 177 Week 15 Recitation Slides. Review CS 177 Week 15 Recitation Slides Review 1 Announcements Final Exam on Friday Dec. 18 th STEW 183 from 1 3 PM Complete your online review of your classes. Your opinion matters!!! Project 6 due Just kidding

More information

Date: Dr. Essam Halim

Date: Dr. Essam Halim Assignment (1) Date: 11-2-2013 Dr. Essam Halim Part 1: Chapter 2 Elementary Programming 1 Suppose a Scanner object is created as follows: Scanner input = new Scanner(System.in); What method do you use

More information

Chapter 5 Lab Methods

Chapter 5 Lab Methods Gaddis_516907_Java 4/10/07 2:10 PM Page 41 Chapter 5 Lab Methods Objectives Be able to write methods Be able to call methods Be able to write javadoc comments Be able to create HTML documentation for our

More information

The for Loop, Accumulator Variables, Seninel Values, and The Random Class. CS0007: Introduction to Computer Programming

The for Loop, Accumulator Variables, Seninel Values, and The Random Class. CS0007: Introduction to Computer Programming The for Loop, Accumulator Variables, Seninel Values, and The Random Class CS0007: Introduction to Computer Programming Review General Form of a switch statement: switch (SwitchExpression) { case CaseExpression1:

More information

Variables, Types, Operations on Numbers

Variables, Types, Operations on Numbers Variables, Types, Operations on Numbers CSE 1310 Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington Updated 9/6/16 1 Summary Variable declaration, initialization,

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading: 2.1-2.2 Copyright 2009 by Pearson Education Data and expressions reading: 2.1 self-check: 1-4 videos: Ch. 2 #1 Copyright

More information

Building Java Programs. Chapter 2: Primitive Data and Definite Loops

Building Java Programs. Chapter 2: Primitive Data and Definite Loops Building Java Programs Chapter 2: Primitive Data and Definite Loops Copyright 2008 2006 by Pearson Education 1 Lecture outline data concepts Primitive types: int, double, char (for now) Expressions: operators,

More information

Lecture 1: Overview of Java

Lecture 1: Overview of Java Lecture 1: Overview of Java What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed for easy Web/Internet applications Widespread

More information

COMP 202 Java in one week

COMP 202 Java in one week CONTENTS: Basics of Programming Variables and Assignment Data Types: int, float, (string) Example: Implementing a calculator COMP 202 Java in one week The Java Programming Language A programming language

More information

Goals. Java - An Introduction. Java is Compiled and Interpreted. Architecture Neutral & Portable. Compiled Languages. Introduction to Java

Goals. Java - An Introduction. Java is Compiled and Interpreted. Architecture Neutral & Portable. Compiled Languages. Introduction to Java Goals Understand the basics of Java. Introduction to Java Write simple Java Programs. 1 2 Java - An Introduction Java is Compiled and Interpreted Java - The programming language from Sun Microsystems Programmer

More information

Computer Components. Software{ User Programs. Operating System. Hardware

Computer Components. Software{ User Programs. Operating System. Hardware Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point

More information

T u r b o P a s k a l i s 7.0

T u r b o P a s k a l i s 7.0 Vilniaus universitetas Matematikos ir informatikos fakultetas Programų sistemų katedra I N F O R M A T I K A T u r b o P a s k a l i s 7.0 Doc. V. Undzėno paskaitų konspektai (skaitoma Fizikos fakulteto

More information

Programming in the Small II: Control

Programming in the Small II: Control Programming in the Small II: Control 188230 Advanced Computer Programming Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University Agenda Selection

More information

CSE 20. SAMPLE FINAL Version A Time: 180 minutes. The following precedence table is provided for your use:

CSE 20. SAMPLE FINAL Version A Time: 180 minutes. The following precedence table is provided for your use: CSE 20 SAMPLE FINAL Version A Time: 180 minutes Name The following precedence table is provided for your use: Precedence of Operators ( ) - (unary),!, ++, -- *, /, % +, - (binary) = = =,!= &&

More information

Programming Language Concepts: Lecture 2

Programming Language Concepts: Lecture 2 Programming Language Concepts: Lecture 2 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2011 PLC 2011, Lecture 2, 6 January 2011 Classes and

More information

Redis Ma as, greitas, galingas. Specialiai VilniusPHP

Redis Ma as, greitas, galingas. Specialiai VilniusPHP Redis Ma as, greitas, galingas Specialiai VilniusPHP 2013.06.06 Sergej Kurakin Na, Jūs mane jau nekarta matėte, tai nieko nesakysiu apie save. Kaip aš susipa inau! Tai buvo prieš keletą metų! Projektas

More information

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University Lecture 2 COMP1406/1006 (the Java course) Fall 2013 M. Jason Hinek Carleton University today s agenda a quick look back (last Thursday) assignment 0 is posted and is due this Friday at 2pm Java compiling

More information

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Tuesday 10:00 AM 12:00 PM * Wednesday 4:00 PM 5:00 PM Friday 11:00 AM 12:00 PM OR

More information

M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014

M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014 M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014 Question One: Choose the correct answer and write it on the external answer booklet. 1. Java is. a. case

More information

Gijos. Gijų modelis Javoje. R.Vaicekauskas, OP, 2017

Gijos. Gijų modelis Javoje. R.Vaicekauskas, OP, 2017 Gijos Gijų modelis Javoje R.Vaicekauskas, OP, 2017 1 Turinys Motyvacija Sukūrimas Valdymas Sinchronizacija Susijusios klasės 2 Motyvacija Gijos reikalingos tam, kad išreikšti lygiagretumą vieno proceso

More information

CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam

CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam Seat Number Name CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam This is a closed book exam. Answer all of the questions on the question paper in the space provided. If

More information

- Thus there is a String class (a large class)

- Thus there is a String class (a large class) Strings - Strings in Java are objects - Thus there is a String class (a large class) - In a statement like this: System.out.println( Hello World ); the Java compiler creates a String object from the quoted

More information

Methods. Bok, Jong Soon

Methods. Bok, Jong Soon Methods Bok, Jong Soon javaexpert@nate.com www.javaexpert.co.kr Methods Enable you to separate statements into code blocks. Can be called whenever appropriate. Can invoke each other. Can call themselves(recursion)

More information

1. Data types ( =13 points)

1. Data types ( =13 points) Software Development I Univ.-Prof. Dr. Alois Ferscha Examination, January 27, 2015 Last name: SAMPLE SOLUTION First name: Institute for Pervasive Computing Lecture hall: Seat: ID: SKZ: Points / Grade:

More information

COMP 202. Java in one week

COMP 202. Java in one week COMP 202 CONTENTS: Basics of Programming Variables and Assignment Data Types: int, float, (string) Example: Implementing a calculator Java in one week The Java Programming Language A programming language

More information

Basic Operations jgrasp debugger Writing Programs & Checkstyle

Basic Operations jgrasp debugger Writing Programs & Checkstyle Basic Operations jgrasp debugger Writing Programs & Checkstyle Suppose you wanted to write a computer game to play "Rock, Paper, Scissors". How many combinations are there? Is there a tricky way to represent

More information

Java Identifiers. Java Language Essentials. Java Keywords. Java Applications have Class. Slide Set 2: Java Essentials. Copyright 2012 R.M.

Java Identifiers. Java Language Essentials. Java Keywords. Java Applications have Class. Slide Set 2: Java Essentials. Copyright 2012 R.M. Java Language Essentials Java is Case Sensitive All Keywords are lower case White space characters are ignored Spaces, tabs, new lines Java statements must end with a semicolon ; Compound statements use

More information

Introduction to Java. Nihar Ranjan Roy. https://sites.google.com/site/niharranjanroy/

Introduction to Java. Nihar Ranjan Roy. https://sites.google.com/site/niharranjanroy/ Introduction to Java https://sites.google.com/site/niharranjanroy/ 1 The Java Programming Language According to sun Microsystems java is a 1. Simple 2. Object Oriented 3. Distributed 4. Multithreaded 5.

More information

Selected Questions from by Nageshwara Rao

Selected Questions from  by Nageshwara Rao Selected Questions from http://way2java.com by Nageshwara Rao Swaminathan J Amrita University swaminathanj@am.amrita.edu November 24, 2016 Swaminathan J (Amrita University) way2java.com (Nageshwara Rao)

More information

Kas yra masyvas? Skaičių masyvo A reikšmės: Elementų indeksai (numeriai): Užrašymas Turbo Paskaliu: A[1] A[2] A[3] A[4] A[5]

Kas yra masyvas? Skaičių masyvo A reikšmės: Elementų indeksai (numeriai): Užrašymas Turbo Paskaliu: A[1] A[2] A[3] A[4] A[5] Masyvas 2013 1 Vienmatis masyvas Veiksmai su masyvo elementais: reikšmių priskyrimas ir išvedimas, paieška, rikiavimas. Masyvų perdavimas procedūros (funkcijos) parametrais. 2 Kas yra masyvas? Masyvu vadinamas

More information