CSCI S-1 Section 4. Deadlines for Homework 2 Problems 1-8 in Parts C and D – Friday, July 3, 17:00 EST Parts E and F – Tuesday, July 7, 17:00 EST.

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

CSCI S-1 Section 5. Deadlines for Problem Set 3 Part A – Friday, July 10, 17:00 EST Parts B – Tuesday, July 14, 17:00 EST Getting the code examples from.
Primitive Data Types and Operations. Introducing Programming with an Example public class ComputeArea { /** Main method */ public static void main(String[]
1 Data types, operations, and expressions Overview l Primitive Data Types l Variable declaration l Arithmetical Operations l Expressions.
BASIC JAVA. Hello World n // Hello world program public class MyFirstJavaProgram { public static void main(String args[]) { char c = 'H'; String s =
1 Data types, operations, and expressions Overview l Format of a Java Application l Primitive Data Types l Variable Declaration l Arithmetic Operations.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 4 Control Structures I: Selection.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
CSCI S-1 Section 3. Deadlines for Homework 2 Problems 1-8 in Parts C and D – Friday, July 3, 17:00 EST Parts E and F – Tuesday, July 7, 17:00 EST.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
DAT602 Database Application Development Lecture 5 JAVA Review.
General Features of Java Programming Language Variables and Data Types Operators Expressions Control Flow Statements.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Chapter 4: Control Structures I J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
Chapter 4: Control Structures I J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design,
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
Building Java Programs Primitive Data and Definite Loops.
 Learn about control structures  Examine relational and logical operators  Explore how to form and evaluate logical (Boolean) expressions  Learn how.
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX.
Sahar Mosleh California State University San MarcosPage 1 Program Control Statement.
1-Dec-15 Additional control structures. 2 The if-else statement The if-else statement chooses which of two statements to execute The if-else statement.
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Java Nuts and Bolts Variables and Data Types Operators Expressions Control Flow Statements Arrays and Strings.
1 Chapter 2: Java Fundamentals cont’d Spring Lory Al Moakar.
S517 Web Programming Assistant Professor Xiaozhong Liu
Java Review if Online Time For loop Quiz on Thursday.
Chapter One Lesson Three DATA TYPES ©
CONTROL STRUCTURE. 2 CHAPTER OBJECTIVES  Learn about control structures.  Examine relational and logical operators.  Explore how to form and evaluate.
Java Part I By Wen Fei, HAO. Program Structure public class ClassName { public static void main(String[] args) { program statements } user defined methods.
Chapter 2: Fundamental Programming Structures in Java Adapted from MIT AITI Slides Control Structures.
1 1 Chapter 2 Elementary Programming. 2 2 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from.
1 Flow of Control Chapter 5. 2 Objectives You will be able to: Use the Java "if" statement to control flow of control within your program.  Use the Java.
Copyright © 2014 by John Wiley & Sons. All rights reserved.1 Decisions and Iterations.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
CSE 110: Programming Language I Matin Saad Abdullah UB 1222.
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.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Chapter 4: Control Structures I
Lecture 4b Repeating With Loops
Elementary Programming
Chapter 4: Control Structures I
Lecture 2: Data Types, Variables, Operators, and Expressions
Primitive Data, Variables, Loops (Maybe)
Chapter 3 Selections Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved
Chapter 2.
Chapter 5 Repetition.
Decision statements. - They can use logic to arrive at desired results
Chapter 4: Control Structures I
מבוא למדעי המחשב, סמסטר א', תשע"א תרגול מס' 2
Chapter 9 Control Structures.
An Introduction to Java – Part I, language basics
בתרגול הקודם אתר הקורס (הודעות, פרטי סגל הקורס, עבודות, פורום, מערכת הגשת תרגילים וכו') שימוש בחלון ה-command, פקודות בסיסות קוד Java: הידור (= קומפילציה)
Fundamentals 2.
Chapter 2: Java Fundamentals
class PrintOnetoTen { public static void main(String args[]) {
Control Structure Chapter 3.
Chapter 2 Programming Basics.
Chapter 3 Selections Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved.
Unit 3: Variables in Java
Control Structure.
Introduction to java Part I By Shenglan Zhang.
Presentation transcript:

CSCI S-1 Section 4

Deadlines for Homework 2 Problems 1-8 in Parts C and D – Friday, July 3, 17:00 EST Parts E and F – Tuesday, July 7, 17:00 EST

Submitting Homework Setup your account by running ~libs1/pub/bin/s1setup Execute the logout command by typing logout and then enter Login again and make a directory to hold all of your homework – mkdir s1 Get into s1 – cd s1 Make a directory for parts C, D (ps21) and E, F (ps22) – mkdir ps21 – mkdir ps22 Test-drive the submit tool by submitting a temporary part 1 – s1submit ps21 NB: Your last submission is the one timestamped and graded.

Primitive Types int double char boolean byte short long float integers: 42, -3 real numbers: 7.35 single characters: ‘a’, ‘X’ logical values: true, false 8-bit integer 16-bit integer 64-bit integer 32-bit real (6-7 digits precision)

Operator Precedence (in decreasing order) Unary operators Multiplicative operators Additive operators Assignment operators +-+- */%*/% +-+- =+=-=*= /=%= =-5 + (4* (3/2)) -1 = 0 =-( ) = * 3 / (5 + 4 * 3 / 2 - 1)

For Loops //Syntax: for (counter= initial_value; logical condition for continuation; update counter) { } //Sequence: //Initialize – Test – Execute Code Block – Update //Example: for( int i=0; i < 5; i++ ) { System.out.println(“i= “ + i); }

Constants class Section4a { public static void main(String [] args) { final int NUMBER_OF_LINES = 10; for(int i = 1; i <= NUMBER_OF_LINES; i++) { System.out.println("HELLO"); } System.out.println ( i );// what’s wrong here? }

Nested For Loops class Section4b { public static void main(String [] args) { for(int i=0; i < 5; i++ ) { System.out.println(“i= ” + i); for (int j=0; j<=i; j++) System.out.println(“\tj = ” + j); }

Type Matters class Section4c { public static void main(String [] args) { int result = 2; for(int i = 1; i <= 5; i++) { result =* result; System.out.println("Result = " + result); } System.out.println("Result = " + result); } // Output is 0. Why?

XPowerN // Write a program that computes X to the power of N, where both X and N are // constants that the user can initialize before compiling the program class Section4d { }

XPowerN // Write a program that computes X to the power of N, where both X and N are // constants that the user can initialize before compiling the program class Section4d { public static void main(String [] args) { final int N = 3; final int X = 5; int result = 1; for (int i = 1; i <= N; i++) result*= X; System.out.println("The result is: " + result); }