CSS 161 Fundamentals of Compu3ng. Assignments, Expressions, Operators, Console input & output October 1, 2012
|
|
- Solomon Reed
- 5 years ago
- Views:
Transcription
1 CSS 161 Fundamentals of Compu3ng Assignments, Expressions, Operators, Console input & output October 1, 2012 Instructor: Uma Murthy CSS SKL 161 A Instructor: Joe McCarthy
2 Outline Introduc3on Recap, reminders Assignments, expressions, and operators Console input and output
3 Who am I? Uma Murthy, Ph.D. o Lecturer, Compu3ng and SoPware Systems, UWB o Naming conven3ons Uma Professor Murthy Dr. Murthy
4 Background Ph.D. from Virginia Tech, 2011 o Digital libraries, informa3on retrieval, personal informa3on management Research associate, Kenan Ins3tute, UNC- Chapel Hill o SoPware agents SoPware Developer, IBM o Incuba3on projects, mainframe emulator (Java development) Master s in Computer Applica3ons, Na3onal Ins3tute of Technology, Trichy, India Bachelor s in Electronics, Bangalore University, India
5 Current Lecturer, Compu3ng and sopware systems, UWB Human Factors Engineer, URCVentures o 3- dimensional reconstruc3on from image sets o Assessing technology and evalua3ng usability
6 Recap
7 Updates/ reminders Assigned readings o Any material in assigned readings is poten3al fodder for exams, regardless of whether we cover it in a lecture, lab or assignment Slides will always be posted on web site o Typically, shortly aper each class Please complete survey if not already done
8 Homework 1 Available by 5pm today, due midnight, Mon, Oct 8
9 Required Textbook Absolute Java, 5 th Edition Walter Savitch & Kenrick Mock Addison-Wesley, th Edition OK, too
10 Supplemental Material (1/2) Java: An Introduction to Problem Solving & Programming, 6th Edition Walter Savitch Addison-Wesley, SavitchCh01.pdf (access via Notes link on course homepage) CSS 161: Fundamentals of Compu3ng
11 Supplemental material (2/2) Prac3ce It! hfp://webster.cs.washington.edu:8080/prac3ceit/ Sign up for a Prac3ce- It account o Make sure to use the school value, "University of Washington Bothell o Add the course, "CSS 161A Autumn 2012 Uma Murthy", to your list of enrolled courses for your account You can do this by clicking My Courses, then Add Course.
12 Java Goal: o o o Write once, run anywhere JDK: Java Developers Kit JRE: Java Run3me Environment Edi3ons o o o o SE: Standard Edi+on EE: Enterprise Edi3on ME: Micro Edi3on (mobile, embedded) Embedded: flash memory, closed systems Versions o 1.0 (1992), (2006), 1.7 (2011)
13 Downloading Java [op3onal] hfp:// o Current: Version 7 update 7 (1.7u7) On Mac, requires Mac OS X or higher o Can also use Version 6 update 35 (1.6u35) hfp:// Supported thru February 2013 We will be wri3ng Java, so we want JDK o Which includes JRE
14
15 Integrated Development Environments (IDEs) Programming tools o Edit text (code) + compile + run o Graphical representa3ons of components We ll be using BlueJ, but you can use others bluej.org eclipse.org netbeans.org
16 Downloading BlueJ
17 Recap Computer program?
18 Recap Computer program? o Set of instruc3ons that tell a computer to execute some task
19 Recap: Intro to Java Class Method main() Iden3fier Reserved word Variable Declara3on Assignment Operator System.out.println() Output: = 30
20 Recap: Intro to Java Class Method main() Iden3fier Reserved word Variable Declara3on Assignment Operator System.out.println() Output: = 30
21
22 Assignments & Expressions Syntax: variable = expression Seman3cs: Evaluate expression, assign value to variable Expression: Constant (1, 1.23, 3.45e6, a, css161, true, false) final static int COURSENUMBER = 161; Variable (num2) expression operator expression Operators: *, /, % +, -
23 Operators & Precedence Can use parentheses to change precedence * 3 (1 + 2) * 3 When operators in an expression have the same precedence, the expression is evaluated from lep to right.
24 Integer division int x = 4; int y = 7; int z = y/x; System.out.println(z); Answer: 1 In integer division, the result is only the integer part and the part aper the decimal is discarded.
25 Focus only on these for now
26 Shorthand assignments Example: Equivalent To: count += 2; count = count + 2; sum -= discount; sum = sum discount; bonus *= 2; bonus = bonus * 2; time /= rushfactor; time = time / rushfactor; change %= 100; change = change % 100; amount *= count1 + count2; amount = amount * (count1 + count2);
27 Increment & Decrement Operators Syntax: variable++ ++variable variable variable Note: can be applied only to a single variable Seman3cs: Set variable to next / previous value Examples int num1 = 1; char char1 = B ; num1++; char1--; Precedence: increment/decrement before/aper use 2*(++num1) 4 2*(num1++) 2
28 Longer expressions with unary operators int y = 3; System.out.println((y++ + y++ + y--)); System.out.println(y);
29 Longer expressions with unary operators int y = 3; System.out.println((y++ + y++ + y--)); System.out.println(y); Answer: 12 4
30 Longer expressions with unary operators int y = 3; System.out.println((y++ + y++ + y--)); (y=3) 3 System.out.println(y); Answer: 12 4
31 Longer expressions with unary operators int y = 3; System.out.println((y++ + y++ + y--)); (y=3) (y=4) System.out.println(y); Answer: 12 4
32 Longer expressions with unary operators int y = 3; System.out.println((y++ + y++ + y--)); (y=3) (y=4) (y=5) y = y 1; System.out.println(y); Answer: 12 4
33 Longer expressions with unary operators int y = 3; System.out.println((y++ + y++ + y--)); (y=3) (y=4) (y=5) y = y 1; System.out.println(y); Answer: 12 4 (y=4)
34 Assignment Compa3bility double float long int short byte char
35 Assignment compatability OK int num1 = 23; int num2 = 'a'; double real1 = 23; Not OK int num3 = 23.0; char c = ; double float long int short byte char
36 Type cas3ng & coercion Syntax: variable = (type) expression Seman3cs Convert expression to type, assign value to variable Only allowed if expression type is compa3ble with variable type Type coercion: Automa3c type cas3ng: double float int Examples short num3 = (short) A ; int num4 = (int) 1.9; //truncate to 1 double num5 = 123; // coercion int num6 = 1.23; // error
37 Console Input & Output System.out A Java object associated with the console (screen) print(), println() Methods associated with the System.out object Syntax: System.out.print(expression) System.out.println([expression]) Seman3cs: Evaluate expression, output its value println: expression is op3onal (hence the square brackets []) output a carriage return / line feed (newline) at end of line
38 Formafed output: printf Syntax: System.out.printf(format[,expression]*) Seman3cs: Use format string to output expression(s) Examples: System.out.printf( Hello ); System.out.printf( Hello\n ); System.out.printf( %5.1f, 1.25); System.out.printf( %-5.1f, 1.25); System.out.printf( $.2f, 1.2);
39 Format string specifiers
40 Console input: Scanner class Not built- in, have to import import java.util.scanner; Next: create an instance of the class Syntax: classname variable = new classname([args]) Seman3cs: Create an instance of classname, ini3alize it with args, assign instance to variable Example: Scanner keyboard = new Scanner(System.in); Create an instance of the Scanner class (in java.u3l package) Ini3alize it to accept input from the system console (System.in) Assign it to keyboard (NB: keyboard not a reserved word)
41 Console Input Using the Scanner Class The method nextint reads one int value typed in at the keyboard and assigns it to a variable: int numberofpods = keyboard.nextint(); The method nextdouble reads one double value typed in at the keyboard and assigns it to a variable: double d1 = keyboard.nextdouble(); Mul3ple inputs must be separated by whitespace and read by mul3ple invoca3ons of the appropriate method o Whitespace is any string of characters, such as blank spaces, tabs, and line breaks that print out as white space 2-41 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
42 Console Input Using the Scanner Class The method next reads one string of non- whitespace characters delimited by whitespace characters such as blanks or the beginning or end of a line Given the code String word1 = keyboard.next(); String word2 = keyboard.next(); and the input line jelly beans The value of word1 would be jelly, and the value of word2 would be beans 2-42 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
43 Console Input Using the Scanner Class The method nextline reads an en3re line of keyboard input The code, String line = keyboard.nextline(); reads in an en3re line and places the string that is read into the variable line The end of an input line is indicated by the escape sequence '\n' o This is the character input when the Enter key is pressed o On the screen it is indicated by the ending of one line and the beginning of the next line When nextline reads a line of text, it reads the '\n' character, so the next reading of input begins on the next line o However, the '\n' does not become part of the string value returned (e.g., the string named by the variable line above does not end with the '\n' character) 2-43 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
44 Keyboard Input Demonstra3on (Part 1 of 2) 2-44 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
45 Keyboard Input Demonstra3on (Part 2 of 2) 2-45 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
46 Another Keyboard Input Demonstra3on (Part 1 of 3) 2-46 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
47 Another Keyboard Input Demonstra3on (Part 2 of 3) 2-47 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
48 Another Keyboard Input Demonstra3on (Part 3 of 3) 2-48 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
49 Lecture 4 stopped here Prac3ce it problems done in class o Self- check 1.6 Legal iden3fiers o Self- check 2.1 Legal in literals o Self- check 2.2 Expressions Prac3ce it problems to try by yourself o Self- check 2.3 (note that some problems have decimal numbers and hence will follow decimal division)
50 Pi}all: Dealing with the Line Terminator, '\n' The method nextline of the class Scanner reads the remainder of a line of text star3ng wherever the last keyboard reading lep off This can cause problems when combining it with different methods for reading from the keyboard such as nextint Given the code, Scanner keyboard = new Scanner(System.in); int n = keyboard.nextint(); String s1 = keyboard.nextline(); String s2 = keyboard.nextline(); and the input, 2 Heads are better than 1 head. what are the values of n, s1, and s2? 2-50 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
51 Pi}all: Dealing with the Line Terminator, '\n' Given the code and input on the previous slide n will be equal to "2", s1 will be equal to "", and s2 will be equal to "heads are better than" If the following results were desired instead n equal to "2", s1 equal to "heads are better than", and s2 equal to "1 head" then an extra invoca3on of nextline would be needed to get rid of the end of line character ('\n') 2-51 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
52 Methods in the Class Scanner (Part 1 of 3) 2-52 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
53 Methods in the Class Scanner (Part 2 of 3) 2-53 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
54 Methods in the Class Scanner (Part 3 of 3) 2-54 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
55 Java Documenta3on for Scanner hfp://download.oracle.com/javase/6/docs/api/java/u3l/scanner.html
56 Programming Tip: Prompt for Input A program should always prompt the user when he or she needs to input some data: System.out.println( "Enter the number of pods followed by"); System.out.println( "the number of peas in a pod:"); 2-56 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
57 Programming Tip: Echo Input Always echo all input that a program receives from the keyboard In this way a user can check that he or she has entered the input correctly o Even though the input is automa3cally displayed as the user enters it, echoing the input may expose subtle errors (such as entering the lefer "O" instead of a zero) 2-57 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
58 Self- Service Checkout Line (Part 1 of 2) 2-58 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
59 Self- Service Checkout Line (Part 2 of 2) 2-59 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
60 The Empty String A string can have any number of characters, including zero characters o "" is the empty string When a program executes the nextline method to read a line of text, and the user types nothing on the line but presses the Enter key, then the nextline Method reads the empty string 2-60 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
61 Other Input Delimiters The delimiters that separate keyboard input can be changed when using the Scanner class For example, the following code could be used to create a Scanner object and change the delimiter from whitespace to "##" Scanner keyboard2 = new Scanner(System.in); Keyboard2.useDelimiter("##"); APer invoca3on of the usedelimiter method, "##" and not whitespace will be the only input delimiter for the input object keyboard Copyright 2010 Pearson Addison- Wesley. All rights reserved.
62 Changing the Input Delimiter (Part 1 of 3) 2-62 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
63 Changing the Input Delimiter (Part 2 of 3) 2-63 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
64 Changing the Input Delimiter (Part 3 of 3) 2-64 Copyright 2010 Pearson Addison- Wesley. All rights reserved.
65 Branching mechanism Next Time
CSS 161 Fundamentals of Compu3ng. Introduc3on to Computers & Java September 26, Instructor: Uma Murthy CSS SKL 161 A Instructor: Joe McCarthy
CSS 161 Fundamentals of Compu3ng Introduc3on to Computers & Java September 26, 2012 Instructor: Uma Murthy CSS SKL 161 A Instructor: Joe McCarthy Outline Update / reminder Introduc3on to Computers Introduc3on
More informationData and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on:
Data and Expressions Data and Expressions Let's explore some other fundamental programming concepts Chapter 2 focuses on: Character Strings Primitive Data The Declaration And Use Of Variables Expressions
More informationObjec+ves. Review. Basics of Java Syntax Java fundamentals. What are quali+es of good sooware? What is Java? How do you compile a Java program?
Objec+ves Basics of Java Syntax Java fundamentals Ø Primi+ve data types Ø Sta+c typing Ø Arithme+c operators Ø Rela+onal operators 1 Review What are quali+es of good sooware? What is Java? Ø Benefits to
More informationCS 152: Data Structures with Java Hello World with the IntelliJ IDE
CS 152: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Electrical and Computer Engineering building
More informationCSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI
CSCI 2010 Principles of Computer Science Data and Expressions 08/09/2013 CSCI 2010 1 Data Types, Variables and Expressions in Java We look at the primitive data types, strings and expressions that are
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationA+ Computer Science -
import java.util.scanner; or just import java.util.*; reference variable Scanner keyboard = new Scanner(System.in); object instantiation Scanner frequently used methods Name nextint() nextdouble() nextfloat()
More informationBasic Computation. Chapter 2
Basic Computation Chapter 2 Increment and Decrement Operators Used to increase (or decrease) the value of a variable by 1 Easy to use, important to recognize The increment operator count++ or ++count The
More informationA+ Computer Science -
Visit us at www.apluscompsci.com Full Curriculum Solutions M/C Review Question Banks Live Programming Problems Tons of great content! www.facebook.com/apluscomputerscience import java.util.scanner; Try
More informationInput. Scanner keyboard = new Scanner(System.in); String name;
Reading Resource Input Read chapter 4 (Variables and Constants) in the textbook A Guide to Programming in Java, pages 77 to 82. Key Concepts A stream is a data channel to or from the operating system.
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University April 21, 2015 Chapter 2: Data and Expressions CS 121 1 / 53 Chapter 2 Part 1: Data Types
More informationChapter. Let's explore some other fundamental programming concepts
Data and Expressions 2 Chapter 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design 2007 Pearson Addison-Wesley. All rights reserved Data and Expressions Let's explore some
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University January 15, 2015 Chapter 2: Data and Expressions CS 121 1 / 1 Chapter 2 Part 1: Data
More information12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.
Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started
More informationProgramming with Java
Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules
More informationCS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++
CS101: Fundamentals of Computer Programming Dr. Tejada stejada@usc.edu www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++ 10 Stacks of Coins You have 10 stacks with 10 coins each that look and feel
More informationCSS 161 Fundamentals of Compu3ng. Flow control (2) October 10, Instructor: Uma Murthy
CSS 161 Fundamentals of Compu3ng Flow control (2) October 10, 2012 Instructor: Uma Murthy Outline Reminders: HW 2 due Monday Today: Errata Review condi3onals Boolean expressions (3.2) Loops (3.3) CSS 161:
More informationECE 122 Engineering Problem Solving with Java
ECE 122 Engineering Problem Solving with Java Lecture 3 Expression Evaluation and Program Interaction Outline Problem: How do I input data and use it in complicated expressions Creating complicated expressions
More informationUniversità degli Studi di Bologna Facoltà di Ingegneria. Principles, Models, and Applications for Distributed Systems M
Università degli Studi di Bologna Facoltà di Ingegneria Principles, Models, and Applications for Distributed Systems M tutor Isam M. Al Jawarneh, PhD student isam.aljawarneh3@unibo.it Mobile Middleware
More informationBASIC INPUT/OUTPUT. Fundamentals of Computer Science
BASIC INPUT/OUTPUT Fundamentals of Computer Science Outline: Basic Input/Output Screen Output Keyboard Input Simple Screen Output System.out.println("The count is " + count); Outputs the sting literal
More informationData Conversion & Scanner Class
Data Conversion & Scanner Class Quick review of last lecture August 29, 2007 ComS 207: Programming I (in Java) Iowa State University, FALL 2007 Instructor: Alexander Stoytchev Numeric Primitive Data Storing
More informationBasic Computation. Chapter 2
Basic Computation Chapter 2 Outline Variables and Expressions The Class String Keyboard and Screen I/O Documentation and Style Variables Variables store data such as numbers and letters. Think of them
More informationEntry 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 informationIntroduction to Java Applications
2 Introduction to Java Applications OBJECTIVES In this chapter you will learn: To write simple Java applications. To use input and output statements. Java s primitive types. Basic memory concepts. To use
More informationAssoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine
More informationLecture 6. Assignments. Java Scanner. User Input 1/29/18. Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4
Assignments Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4 Lecture 6 Complete for Lab 4, Project 1 Note: Slides 12 19 are summary slides for Chapter 2. They overview much of what we covered but are not complete.
More informationTester 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 informationCS110: PROGRAMMING LANGUAGE I
CS110: PROGRAMMING LANGUAGE I Computer Science Department Lecture 4: Java Basics (II) A java Program 1-2 Class in file.java class keyword braces {, } delimit a class body main Method // indicates a comment.
More informationElementary 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 informationCS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 06 / 02 / 2015 Instructor: Michael Eckmann Today s Topics Operators continue if/else statements User input Operators + when used with numeric types (e.g. int,
More informationSTUDENT LESSON A7 Simple I/O
STUDENT LESSON A7 Simple I/O Java Curriculum for AP Computer Science, Student Lesson A7 1 STUDENT LESSON A7 Simple I/O INTRODUCTION: The input and output of a program s data is usually referred to as I/O.
More informationCS111: PROGRAMMING LANGUAGE II
1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1: Introduction Lecture Contents 2 Course info Why programming?? Why Java?? Write once, run anywhere!! Java basics Input/output Variables
More informationBasic Computation. Chapter 2
Walter Savitch Frank M. Carrano Basic Computation Chapter 2 Outline Variables and Expressions The Class String Keyboard and Screen I/O Documentation and Style Variables Variables store data such as numbers
More informationCOMP String and Console I/O. Yi Hong May 18, 2015
COMP 110-001 String and Console I/O Yi Hong May 18, 2015 Announcements Labs 0 & 1 are due today by 11:59pm Homework 0 grades are posted Office hours are fixed: MW 3-4pm, or by appointment Review of How
More informationCOMP Primitive and Class Types. Yi Hong May 14, 2015
COMP 110-001 Primitive and Class Types Yi Hong May 14, 2015 Review What are the two major parts of an object? What is the relationship between class and object? Design a simple class for Student How to
More informationFull file at
Chapter 2 Console Input and Output Multiple Choice 1) Valid arguments to the System.out object s println method include: (a) Anything with double quotes (b) String variables (c) Variables of type int (d)
More informationFull file at
Java Programming, Fifth Edition 2-1 Chapter 2 Using Data within a Program At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional
More informationChapter 2: Basic Elements of Java
Chapter 2: Basic Elements of Java TRUE/FALSE 1. The pair of characters // is used for single line comments. ANS: T PTS: 1 REF: 29 2. The == characters are a special symbol in Java. ANS: T PTS: 1 REF: 30
More informationLecture Set 2: Starting Java
Lecture Set 2: Starting Java 1. Java Concepts 2. Java Programming Basics 3. User output 4. Variables and types 5. Expressions 6. User input 7. Uninitialized Variables 0 This Course: Intro to Procedural
More informationCOMP 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 informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics
Java Programming, Sixth Edition 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional Projects Additional
More informationLecture Set 2: Starting Java
Lecture Set 2: Starting Java 1. Java Concepts 2. Java Programming Basics 3. User output 4. Variables and types 5. Expressions 6. User input 7. Uninitialized Variables 0 This Course: Intro to Procedural
More informationA variable is a name for a location in memory A variable must be declared
Variables A variable is a name for a location in memory A variable must be declared, specifying the variable's name and the type of information that will be held in it data type variable name int total;
More informationChapter Overview. C++ Basics. Variables and Assignments. Variables and Assignments. Keywords. Identifiers. 2.1 Variables and Assignments
Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Copyright 2011 Pearson Addison-Wesley. All rights
More informationConsole Input and Output
Solutions Manual for Absolute C++ 4th Edition by Walter Savitch Link full download Test bank: https://getbooksolutions.com/download/test-bank-for-absolute-c-4th-edition-by-savitch/ Link full download Solutions
More informationLecture Notes. System.out.println( Circle radius: + radius + area: + area); radius radius area area value
Lecture Notes 1. Comments a. /* */ b. // 2. Program Structures a. public class ComputeArea { public static void main(string[ ] args) { // input radius // compute area algorithm // output area Actions to
More information2: Basics of Java Programming
2: Basics of Java Programming CSC 1051 Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/
More informationHello World. n Variables store information. n You can think of them like boxes. n They hold values. n The value of a variable is its current contents
Variables in a programming language Basic Computation (Savitch, Chapter 2) TOPICS Variables and Data Types Expressions and Operators Integers and Real Numbers Characters and Strings Input and Output Variables
More informationReview Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013
Review Chapters 1 to 4 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Introduction to Java Chapters 1 and 2 The Java Language Section 1.1 Data & Expressions Sections 2.1 2.5 Instructor:
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 2 : C# Language Basics Lecture Contents 2 The C# language First program Variables and constants Input/output Expressions and casting
More informationLecture 8 " INPUT " Instructor: Craig Duckett
Lecture 8 " INPUT " Instructor: Craig Duckett Assignments Assignment 2 Due TONIGHT Lecture 8 Assignment 1 Revision due Lecture 10 Assignment 2 Revision Due Lecture 12 We'll Have a closer look at Assignment
More informationCourse Outline. Introduction to java
Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.
More informationAP Computer Science Unit 1. Writing Programs Using BlueJ
AP Computer Science Unit 1. Writing Programs Using BlueJ 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More informationIntroduction to Java Unit 1. Using BlueJ to Write Programs
Introduction to Java Unit 1. Using BlueJ to Write Programs 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More informationIntroduction to Java Applications; Input/Output and Operators
www.thestudycampus.com Introduction to Java Applications; Input/Output and Operators 2.1 Introduction 2.2 Your First Program in Java: Printing a Line of Text 2.3 Modifying Your First Java Program 2.4 Displaying
More informationSection 2: Introduction to Java. Historical note
The only way to learn a new programming language is by writing programs in it. - B. Kernighan & D. Ritchie Section 2: Introduction to Java Objectives: Data Types Characters and Strings Operators and Precedence
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University August 21, 2017 Chapter 2: Data and Expressions CS 121 1 / 51 Chapter 1 Terminology Review
More informationIntroduction to Software Development (ISD) David Weston and Igor Razgon
Introduction to Software Development (ISD) David Weston and Igor Razgon Autumn term 2013 Course book The primary book supporting the ISD module is: Java for Everyone, by Cay Horstmann, 2nd Edition, Wiley,
More informationObject-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 informationAP Computer Science Unit 1. Writing Programs Using BlueJ
AP Computer Science Unit 1. Writing Programs Using BlueJ 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More informationArray Basics: Outline
Array Basics: Outline More Arrays (Savitch, Chapter 7) TOPICS Array Basics Arrays in Classes and Methods Programming with Arrays Searching and Sorting Arrays Multi-Dimensional Arrays Static Variables and
More informationRobots. Byron Weber Becker. chapter 6
Using Variables Robots Learning to Program with Java Byron Weber Becker chapter 6 Announcements (Oct 5) Chapter 6 You don t have to spend much time on graphics in Ch6 Just grasp the concept Reminder: Reading
More informationChapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 2 C++ Basics 1 Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-3 2.1 Variables and Assignments 2
More informationAP Computer Science Unit 1. Programs
AP Computer Science Unit 1. Programs Open DrJava. Under the File menu click on New Java Class and the window to the right should appear. Fill in the information as shown and click OK. This code is generated
More informationFirst Java Program - Output to the Screen
First Java Program - Output to the Screen These notes are written assuming that the reader has never programmed in Java, but has programmed in another language in the past. In any language, one of the
More informationComputational Expression
Computational Expression Variables, Primitive Data Types, Expressions Janyl Jumadinova 28-30 January, 2019 Janyl Jumadinova Computational Expression 28-30 January, 2019 1 / 17 Variables Variable is a name
More information2.8. Decision Making: Equality and Relational Operators
Page 1 of 6 [Page 56] 2.8. Decision Making: Equality and Relational Operators A condition is an expression that can be either true or false. This section introduces a simple version of Java's if statement
More informationCONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2
CONTENTS: Compilation Data and Expressions COMP 202 More on Chapter 2 Programming Language Levels There are many programming language levels: machine language assembly language high-level language Java,
More informationChapter 2 Part 2 Edited by JJ Shepherd, James O Reilly
Basic Computation Chapter 2 Part 2 Edited by JJ Shepherd, James O Reilly Parentheses and Precedence Parentheses can communicate the order in which arithmetic operations are performed examples: (cost +
More informationReading Input from Text File
Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Lab 5 Reading Input from Text File Eng. Mohammed Alokshiya November 2, 2014 The simplest
More informationDefine a method vs. calling a method. Chapter Goals. Contents 1/21/13
CHAPTER 2 Define a method vs. calling a method Line 3 defines a method called main Line 5 calls a method called println, which is defined in the Java library You will learn later how to define your own
More informationIntroduction To Java. Chapter 1. Origins of the Java Language. Origins of the Java Language. Objects and Methods. Origins of the Java Language
Chapter 1 Getting Started Introduction To Java Most people are familiar with Java as a language for Internet applications We will study Java as a general purpose programming language The syntax of expressions
More informationJava Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2
Java Foundations Introduction to Program Design and Data Structures 4th Edition Lewis TEST BANK Full download at : https://testbankreal.com/download/java-foundations-introduction-toprogram-design-and-data-structures-4th-edition-lewis-test-bank/
More informationConstants. Why Use Constants? main Method Arguments. CS256 Computer Science I Kevin Sahr, PhD. Lecture 25: Miscellaneous
CS256 Computer Science I Kevin Sahr, PhD Lecture 25: Miscellaneous 1 main Method Arguments recall the method header of the main method note the argument list public static void main (String [] args) we
More informationEntry Point of Execution: the main Method. Elementary Programming. Compile Time vs. Run Time. Learning Outcomes
Entry Point of Execution: the main Method Elementary Programming EECS2030: Advanced Object Oriented Programming Fall 2017 CHEN-WEI WANG For now, all your programming exercises will be defined within the
More informationWe now start exploring some key elements of the Java programming language and ways of performing I/O
We now start exploring some key elements of the Java programming language and ways of performing I/O This week we focus on: Introduction to objects The String class String concatenation Creating objects
More informationCS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 06 / 03 / 2015 Instructor: Michael Eckmann Today s Topics Finish up discussion of projected homeruns 162 as a constant (final) double vs. int in calculation Scanner
More informationBasic Programming Elements
Chapter 2 Basic Programming Elements Lecture slides for: Java Actually: A Comprehensive Primer in Programming Khalid Azim Mughal, Torill Hamre, Rolf W. Rasmussen Cengage Learning, 2008. ISBN: 978-1-844480-933-2
More informationChapter 4: Conditionals and Recursion
Chapter 4: Conditionals and Recursion Think Java: How to Think Like a Computer Scientist 5.1.2 by Allen B. Downey Agenda The modulus operator Random Number Generation Conditional Execution Alternative
More informationB.V. Patel Institute of BMC & IT, UTU 2014
BCA 3 rd Semester 030010301 - Java Programming Unit-1(Java Platform and Programming Elements) Q-1 Answer the following question in short. [1 Mark each] 1. Who is known as creator of JAVA? 2. Why do we
More informationChapter 2. C++ Basics
Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-2 2.1 Variables and Assignments Variables
More informationComputational Expression
Computational Expression Scanner, Increment/Decrement, Conversion Janyl Jumadinova 17 September, 2018 Janyl Jumadinova Computational Expression 17 September, 2018 1 / 11 Review: Scanner The Scanner class
More informationSt. Edmund Preparatory High School Brooklyn, NY
AP Computer Science Mr. A. Pinnavaia Summer Assignment St. Edmund Preparatory High School Name: I know it has been about 7 months since you last thought about programming. It s ok. I wouldn t want to think
More informationLecture 6. Assignments. Summary - Variables. Summary Program Parts 1/29/18. Reading: 3.1, 3.2, 3.3, 3.4
Assignments Lecture 6 Complete for Project 1 Reading: 3.1, 3.2, 3.3, 3.4 Summary Program Parts Summary - Variables Class Header (class name matches the file name prefix) Class Body Because this is a program,
More informationPrimitive Data Types: Intro
Primitive Data Types: Intro Primitive data types represent single values and are built into a language Java primitive numeric data types: 1. Integral types (a) byte (b) int (c) short (d) long 2. Real types
More informationCOSC 123 Computer Creativity. Introduction to Java. Dr. Ramon Lawrence University of British Columbia Okanagan
COSC 123 Computer Creativity Introduction to Java Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Key Points 1) Introduce Java, a general-purpose programming language,
More informationObject Oriented Programming. Java-Lecture 1
Object Oriented Programming Java-Lecture 1 Standard output System.out is known as the standard output object Methods to display text onto the standard output System.out.print prints text onto the screen
More informationCOMP 202 Java in one week
COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of
More informationIT 374 C# and Applications/ IT695 C# Data Structures
IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation
More informationLecture 9. Assignment. Logical Operations. Logical Operations - Motivation 2/8/18
Assignment Lecture 9 Logical Operations Formatted Print Printf Increment and decrement Read through 3.9, 3.10 Read 4.1. 4.2, 4.3 Go through checkpoint exercise 4.1 Logical Operations - Motivation Logical
More informationChapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style 3 2.1 Variables and Assignments Variables and
More informationExam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming
Exam 1 Prep Dr. Demetrios Glinos University of Central Florida COP3330 Object Oriented Programming Progress Exam 1 is a Timed Webcourses Quiz You can find it from the "Assignments" link on Webcourses choose
More informationArray Basics: Outline
Array Basics: Outline More Arrays (Savitch, Chapter 7) TOPICS Array Basics Arrays in Classes and Methods Programming with Arrays Searching and Sorting Arrays Multi-Dimensional Arrays Static Variables and
More informationSection 2.2 Your First Program in Java: Printing a Line of Text
Chapter 2 Introduction to Java Applications Section 2.2 Your First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using a. Two
More informationChapter 2 ELEMENTARY PROGRAMMING
Chapter 2 ELEMENTARY PROGRAMMING Lecture notes for computer programming 1 Faculty of Engineering and Information Technology Prepared by: Iyad Albayouk ١ Objectives To write Java programs to perform simple
More informationCOMP 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 informationCIS 110: Introduction to Computer Programming
CIS 110: Introduction to Computer Programming Lecture 3 Express Yourself ( 2.1) 9/16/2011 CIS 110 (11fa) - University of Pennsylvania 1 Outline 1. Data representation and types 2. Expressions 9/16/2011
More informationObjectives. Primitive Types, Strings, and Console I/O. Variables and Values. Outline. Naming and Declaring Variables. Variables and Values
Objectives Primitive Types, Strings, and Console I/O Chapter 2 become familiar with Java primitive types (numbers, characters, etc.) learn about assignment statements and expressions learn about strings
More informationing execution. That way, new results can be computed each time the Class The Scanner
ing execution. That way, new results can be computed each time the run, depending on the data that is entered. The Scanner Class The Scanner class, which is part of the standard Java class provides convenient
More informationData and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence
Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public
More information