CP122 Computer Science I. Chapter 2: Data Types, Variables, and I/O
|
|
- Gilbert Alexander
- 5 years ago
- Views:
Transcription
1 CP122 Computer Science I Chapter 2: Data Types, Variables, and I/O
2 Course blogger?
3 QRC Tutoring
4 Tech News! President Obama proposes overhaul of NSA data collection
5 Tech News! President Obama proposes overhaul of NSA data collection Google Glass partners with Ray-Ban
6 Hacker's Tip of the Day: Use Linux Open Source Software
7 Hacker's Tip of the Day: Use Linux Open Source Software Free
8 Hacker's Tip of the Day: Use Linux Open Source Software Free *cough* Better *cough*
9 Using IDEs Eclipse JGrasp BlueJ Netbeans Dr. Java
10 Chapter 2: Fundamental Data Types Variables and data types Arithmetic Binary data Input/Output Strings
11 Data Types Every value in a Java program has a type
12 Data Types Every value in a Java program has a type That is, what kind of data does the value store?
13 Data Types Every value in a Java program has a type That is, what kind of data does the value store? Binary data: all 1's and 0's
14 Data Types Every value in a Java program has a type That is, what kind of data does the value store? Binary data: all 1's and 0's How are the 1's and 0's interpreted?
15 A Familiar Type: A Literal String public class MyFirstProgram { public static void main(string[] args) { System.out.println( This is my first program! ); } }
16 Other Data Types int (integer) - Any whole number Examples: 15, -50, 0
17 Other Data Types int (integer) - Any whole number Examples: 15, -50, 0 double (floating-point number) A number with the decimal part Examples: , 0.25, 1E6
18 Expressions Expression : a combination of variables, literals, and operators Examples: * * (6-2)
19 Microquiz What are the data types of the following values? I heart CS
20 Variables Variable: a named and typed place to store a value int userage = 19;
21 Variables Variable: a named and typed place to store a value int userage = 19; int is the type of the new variable.
22 Variables Variable: a named and typed place to store a value int userage = 19; userage is the name of the variable.
23 Variables Variable: a named and typed place to store a value int userage = 19; 19 is the initial value for the variable.
24 Variables Variable: a named and typed place to store a value int userage = 19; = is the assignment operator.
25 Variables Variable: a named and typed place to store a value int userage = 19; double hourlypay = 31.50;
26 Variables Variable: a named and typed place to store a value int userage = 19; double hourlypay = 31.50; String avatarname = n00bdestroyer ;
27 Identifier Name Rules - Consist of letters, digits, underscores, and dollar signs (do not use dollar signs) - Cannot use spaces or other symbols - Java keywords are illegal (public, static, void)
28 Identifier Name Style Rules - Start variable names with a lowercase letter - Capitalize subsequent words in the variable (camelcase) userage hourpay - Start class names with an uppercase letter - Use UpperCamelCase
29 Identifier Name Style Rules - Choose descriptive variable names! double x3 = mm2 / i6;
30 Identifier Name Style Rules - Choose descriptive variable names! double x3 = mm2 / i6; double hourlypay = salary / hoursworked;
31 Assignment Operator int userage = 19;... userage = 20; userage = ; userage = userdays / 365;
32 Other Operators int userage = 19; // Increment userage (add 1 to it) userage = userage + 1;
33 Other Operators int userage = 19; // Increment userage (add 1 to it) userage = userage + 1; // Increment userage (add 1 to it) userage += 1;
34 Other Operators int userage = 19; // Increment userage (add 1 to it) userage = userage + 1; // Increment userage (add 1 to it) userage += 1; // Increment userage (add 1 to it) userage++;
35 Calculator.java
36 Storing Numbers How many distinct values can you represent given one binary bit?
37 Storing Numbers How many distinct values can you represent given one binary bit? 8 bits together are called a byte. How many values can be represented with a byte?
38 Challenge Question What is the largest value that we can store in an int variable? What does this tell us about the number of bits used to store each int variable?
39 Table of Sizes Bit Value 0 or 1 Byte 8 bits Kilobyte 1024 bytes Megabyte 1024 kilobytes Gigabyte 1024 megabytes Terabyte 1024 gigabytes Petabyte 1024 terabytes Exabyte 1024 petabytes
40 Java Primitive Data Types Integer Types byte short int long : : : : Floating-Point Types byte bytes bytes bytes float : 4 bytes double : 8 bytes Other Types char : 2 bytes boolean : 1 bit
41 Binary Numbers How do we represent the decimal number 13 in binary?
42 Binary Numbers What decimal number does the binary number represent?
43 Binary Data Microquiz Convert to binary: Convert to decimal:
44 Crazy Microquiz Convert from decimal to base Convert from decimal to hexadecimal (base 16) 11 33
45 There are only 10 types of people in the world: those who understand binary and those who don't.
46 There are only 10 types of people in the world: those who understand ternary, those who don't, and those who thought this was going to be a binary joke.
47 Did you know that Halloween is the same day as Christmas? =
48 Did you know that Halloween is the same day as Christmas? = 25 DEC = 31 OCT
49 String Variables // Declare a String variable and initialize it String username = mwhitehead ; System.out.println(userName);
50 String Methods // Convert a String into an integer String useragestring = 23 ; int userage = Integer.parseInt(userAgeString);
51 More String Methods // Convert a String into an integer String useragestring = 23 ; int userage = Integer.parseInt(userAgeString); // Convert a String into a double String gpastring = 3.42 ; double gpa = Double.parseDouble(gpaString);
52 More String Methods // Extract a single character from a String String fullname = Stephanie Brown ; char firstletter = fullname.charat(0);
53 More String Methods // Extract a single character from a String String fullname = Stephanie Brown ; char firstletter = fullname.charat(0); // Extract the first nine characters from a String String fullname = Stephanie Brown ; String firstname = fullname.substring(0, 9);
54 More String Methods // Extract a single character from a String String fullname = Stephanie Brown ; char firstletter = fullname.charat(0); Inclusive start index // Extract the first nine characters from a String String fullname = Stephanie Brown ; String firstname = fullname.substring(0, 9);
55 More String Methods // Extract a single character from a String String fullname = Stephanie Brown ; char firstletter = fullname.charat(0); Exclusive end index // Extract the first nine characters from a String String fullname = Stephanie Brown ; String firstname = fullname.substring(0, 9);
56 More String Methods // Concatenate two strings into one String firstname = Stephanie ; String lastname = Brown ; String fullname = firstname + lastname;
57 Escape Sequences // Insert a newline character System.out.println( Hello \n World );
58 Escape Sequences // Insert a newline character System.out.println( Hello \n World ); // Insert a literal backslash (\) System.out.println( Saved in C:\\Documents );
59 Getting User Input import java.util.scanner;... // Create a Scanner object Scanner myscanner = new Scanner(System.in); // Read in an integer that the user types in int userint = myscanner.nextint();
60 Getting User Input import java.util.scanner;... // Create a Scanner object Scanner myscanner = new Scanner(System.in); // Read in an integer that the user types in int userint = myscanner.nextint(); // Read in a whole line as a String String line = myscanner.nextline();
61 User Input : Dialog Box import javax.swing.joptionpane;... // Create a pop-up window String prompt = Please enter your username ; String username = JOptionPane.showInputDialog(prompt);
62 User Input : Dialog Box import javax.swing.joptionpane;... // Create a pop-up window String prompt = Please enter your username ; String username = JOptionPane.showInputDialog(prompt); String prompt2 = Please enter your password ; String password = JOptionPane.showInputDialog(prompt2);
63 User Input : Dialog Box import javax.swing.joptionpane;... // Create a pop-up window String prompt = Please enter your username ; String username = JOptionPane.showInputDialog(prompt); String prompt2 = Please enter your password ; String password = JOptionPane.showInputDialog(prompt2); JOptionPane.showMessageDialog(null, Logged in! );
64 BetterCalculator.java
65 Break!
CP122 Computer Science I. Binary, Strings, Conditionals, User Input
CP122 Computer Science I Binary, Strings, Conditionals, User Input Everysight Raptor AR cycling glasses ($499) Tech News! Tech News! Everysight Raptor AR cycling glasses ($499) 42% of US children ages
More informationCP122 Computer Science I. Chapter 3: Methods/Functions
CP122 Computer Science I Chapter 3: Methods/Functions Offline viewing of some Netflix shows now available Tech News Tech News Offline viewing of some Netflix shows now available Consumer Review Fairness
More informationCP122 Computer Science I. Chapter 2: Using Objects
CP122 Computer Science I Chapter 2: Using Objects Tech News! Cyber Monday: $3.3B https://youtu.be/r4rfcay9fiq Tech News! Cyber Monday: $3.3B https://youtu.be/r4rfcay9fiq Small drone warfare https://cdn1.tnwcdn.com/wpcontent/blogs.dir/1/files/2016/11/ezgif.comoptimize-1-1.mp4
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
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 informationPROGRAMMING FUNDAMENTALS
PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write
More informationVariables, Constants, and Data Types
Variables, Constants, and Data Types Strings and Escape Characters Primitive Data Types Variables, Initialization, and Assignment Constants Reading for this lecture: Dawson, Chapter 2 http://introcs.cs.princeton.edu/python/12types
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 informationChapter 02: Using Data
True / False 1. A variable can hold more than one value at a time. ANSWER: False REFERENCES: 54 2. The int data type is the most commonly used integer type. ANSWER: True REFERENCES: 64 3. Multiplication,
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 informationGetting started with Java
Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving
More informationPRIMITIVE VARIABLES. CS302 Introduction to Programming University of Wisconsin Madison Lecture 3. By Matthew Bernstein
PRIMITIVE VARIABLES CS302 Introduction to Programming University of Wisconsin Madison Lecture 3 By Matthew Bernstein matthewb@cs.wisc.edu Variables A variable is a storage location in your computer Each
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 informationCEN 414 Java Programming
CEN 414 Java Programming Instructor: H. Esin ÜNAL SPRING 2017 Slides are modified from original slides of Y. Daniel Liang WEEK 2 ELEMENTARY PROGRAMMING 2 Computing the Area of a Circle public class ComputeArea
More informationStarting Out with Java: From Control Structures through Data Structures 3e (Gaddis and Muganda) Chapter 2 Java Fundamentals
Starting Out with Java: From Control Structures through Data Structures 3e (Gaddis and Muganda) Chapter 2 Java Fundamentals 2.1 Multiple Choice Questions 1) Which one of the following would contain the
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
More informationWentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics
WIT COMP1000 Java Basics Java Origins Java was developed by James Gosling at Sun Microsystems in the early 1990s It was derived largely from the C++ programming language with several enhancements Java
More information5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.
Today! Build HelloWorld yourself in BlueJ and Eclipse. Look at all the Java keywords. Primitive Types. HelloWorld in BlueJ 1. Find BlueJ in the start menu, but start the Select VM program instead (you
More informationChapter 2 Primitive Data Types and Operations
Chapter 2 Primitive Data Types and Operations 2.1 Introduction You will be introduced to Java primitive data types and related subjects, such as variables constants, data types, operators, and expressions.
More information4 Programming Fundamentals. Introduction to Programming 1 1
4 Programming Fundamentals Introduction to Programming 1 1 Objectives At the end of the lesson, the student should be able to: Identify the basic parts of a Java program Differentiate among Java literals,
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 informationGaddis: Starting Out with Java: From Control Structures through Objects, 6/e
Chapter 2 MULTIPLE CHOICE 1. Which one of the following would contain the translated Java byte code for a program named Demo? a. Demo.java b. Demo.code c. Demo.class d. Demo.byte 2. To compile a program
More informationCP122 CS I. Chapter 11: File I/O and Exceptions
CP122 CS I Chapter 11: File I/O and Exceptions Waymo full autonomy vehicles Tech News! Tech News! Waymo full autonomy vehicles CMU and Pitt researchers use AI with fmri to detect suicidal thoughts with
More informationArithmetic and IO. 25 August 2017
Arithmetic and IO 25 August 2017 Submissions you can submit multiple times to the homework dropbox file name: uppercase first letter, Yourlastname0829.java the system will use the last submission before
More informationCP122 CS I. Chapter 11: File I/O and Exceptions
CP122 CS I Chapter 11: File I/O and Exceptions Amazon completes first commercial drone delivery Tech News! Tech News! Amazon completes first commercial drone delivery DNC hack was due to phishing scam.
More informationCMSC131. Introduction to your Introduction to Java. Why Java?
CMSC131 Introduction to your Introduction to Java Why Java? It s a popular language in both industry and introductory programming courses. It makes use of programming structures and techniques that can
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 informationCP122 CS I. Chapter 7: File I/O and Exceptions
CP122 CS I Chapter 7: File I/O and Exceptions Tech News! Triathlete in Australia hit by falling drone Tech News! Triathlete in Australia hit by falling drone 3D Printed drones in 24 hours using Stratasys
More informationCS 302: Introduction to Programming
CS 302: Introduction to Programming Lectures 2-3 CS302 Summer 2012 1 Review What is a computer? What is a computer program? Why do we have high-level programming languages? How does a high-level program
More informationChapter 2 Elementary Programming
Chapter 2 Elementary Programming Part I 1 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from this chapter, you will learn how to solve practical
More informationWhat methods does the String class provide for ignoring case sensitive situations?
Nov. 20 What methods does the String class provide for ignoring case sensitive situations? What is a local variable? What is the span of a local variable? How many operands does a conditional operator
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 informationDatatypes, Variables, and Operations
Datatypes, Variables, and Operations 1 Primitive Type Classification 2 Numerical Data Types Name Range Storage Size byte 2 7 to 2 7 1 (-128 to 127) 8-bit signed short 2 15 to 2 15 1 (-32768 to 32767) 16-bit
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 informationObject oriented programming. Instructor: Masoud Asghari Web page: Ch: 3
Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning
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 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 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 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 information4. If the following Java statements are executed, what will be displayed?
Chapter 2 MULTIPLE CHOICE 1. To compile a program named First, use the following command a. java First.java b. javac First c. javac First.java d. compile First.javac 2. A Java program must have at least
More informationFundamentals of Programming Data Types & Methods
Fundamentals of Programming Data Types & Methods By Budditha Hettige Overview Summary (Previous Lesson) Java Data types Default values Variables Input data from keyboard Display results Methods Operators
More informationSoftware Practice 1 Basic Grammar
Software Practice 1 Basic Grammar Basic Syntax Data Type Loop Control Making Decision Prof. Joonwon Lee T.A. Jaehyun Song Jongseok Kim (42) T.A. Sujin Oh Junseong Lee (43) 1 2 Java Program //package details
More informationCS 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 informationSoftware Practice 1 - Basic Grammar Basic Syntax Data Type Loop Control Making Decision
Software Practice 1 - Basic Grammar Basic Syntax Data Type Loop Control Making Decision Prof. Hwansoo Han T.A. Minseop Jeong T.A. Wonseok Choi 1 Java Program //package details public class ClassName {
More informationComputer 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 informationKey Differences Between Python and Java
Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.
More informationMr. Monroe s Guide to Mastering Java Syntax
Mr. Monroe s Guide to Mastering Java Syntax Getting Started with Java 1. Download and install the official JDK (Java Development Kit). 2. Download an IDE (Integrated Development Environment), like BlueJ.
More informationBIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic
BIT 3383 Java Programming Sem 1 Session 2011/12 Chapter 2 JAVA basic Objective: After this lesson, you should be able to: declare, initialize and use variables according to Java programming language guidelines
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 informationLecture 2 Tao Wang 1
Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors
More informationCS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University
CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Overview of Source Code Components Comments Library declaration Classes Functions Variables Comments Can
More informationChapter 2 Working with Data Types and Operators
JavaScript, Fourth Edition 2-1 Chapter 2 Working with Data Types and Operators At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics
More informationChapter 2: Programming Concepts
Chapter 2: Programming Concepts Objectives Students should Know the steps required to create programs using a programming language and related terminology. Be familiar with the basic structure of a Java
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 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 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 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 informationChapter 2 Primitive Data Types and Operations. Objectives
Chapter 2 Primitive Data Types and Operations Prerequisites for Part I Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word Chapter 1 Introduction to Computers, Programs,
More informationHandout 3 cs180 - Programming Fundamentals Fall 17 Page 1 of 6. Handout 3. Strings and String Class. Input/Output with JOptionPane.
Handout 3 cs180 - Programming Fundamentals Fall 17 Page 1 of 6 Handout 3 Strings and String Class. Input/Output with JOptionPane. Strings In Java strings are represented with a class type String. Examples:
More informationHUDSONVILLE HIGH SCHOOL COURSE FRAMEWORK
HUDSONVILLE HIGH SCHOOL COURSE FRAMEWORK COURSE / SUBJECT Introduction to Programming KEY COURSE OBJECTIVES/ENDURING UNDERSTANDINGS OVERARCHING/ESSENTIAL SKILLS OR QUESTIONS Introduction to Java Java Essentials
More informationFall 2017 CISC124 9/16/2017
CISC124 Labs start this week in JEFF 155: Meet your TA. Check out the course web site, if you have not already done so. Watch lecture videos if you need to review anything we have already done. Problems
More informationWhat did we talk about last time? Examples switch statements
Week 4 - Friday What did we talk about last time? Examples switch statements History of computers Hardware Software development Basic Java syntax Output with System.out.print() Mechanical Calculation
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 informationProgramming in Java
320341 Programming in Java Fall Semester 2015 Lecture 2: Fundamental Structures Instructor: Jürgen Schönwälder Slides: Bendick Mahleko Outline - Program structure - Data types - Variables - Constants -
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 informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
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 informationLesson 02 Data Types and Statements. MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL
Lesson 02 Data Types and Statements MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL Topics Covered Statements Variables Constants Data Types
More informationData types Expressions Variables Assignment. COMP1400 Week 2
Data types Expressions Variables Assignment COMP1400 Week 2 Data types Data come in different types. The type of a piece of data describes: What the data means. What we can do with it. Primitive types
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 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 informationCP122 CS I. Chapter 13: Recursion
CP122 CS I Chapter 13: Recursion Russian law banning VPNs comes into effect today Tech News! Tech News! Russian law banning VPNs comes into effect today Shelley: AI to write horror story openings THE PATH
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationJAVA Programming Fundamentals
Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol
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 informationLast Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings
University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Writing a Simple Java Program Intro to Variables Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch
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 informationFull file at
Gaddis: Starting Out with Java: Early Objects, 4/e Test Bank 1 Chapter 2 Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) Which of the
More information13 th Windsor Regional Secondary School Computer Programming Competition
SCHOOL OF COMPUTER SCIENCE 13 th Windsor Regional Secondary School Computer Programming Competition Hosted by The School of Computer Science, University of Windsor WORKSHOP I [ Overview of the Java/Eclipse
More informationBasic computer skills such as using Windows, Internet Explorer, and Microsoft Word. Chapter 1 Introduction to Computers, Programs, and Java
Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word Chapter 1 Introduction to Computers, Programs, and Java Chapter 2 Primitive Data Types and Operations Chapter 3 Selection
More information4 WORKING WITH DATA TYPES AND OPERATIONS
WORKING WITH NUMERIC VALUES 27 4 WORKING WITH DATA TYPES AND OPERATIONS WORKING WITH NUMERIC VALUES This application will declare and display numeric values. To declare and display an integer value in
More informationJava Module Lesson 2A Practice Exercise
Java Module Lesson 2A Practice Exercise Name Completion Complete each sentence or statement. 1. The three main data types used in a typical Java program are:,, and. 2. In general, data types that are simple
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 informationMODULE 02: BASIC COMPUTATION IN JAVA
MODULE 02: BASIC COMPUTATION IN JAVA Outline Variables Naming Conventions Data Types Primitive Data Types Review: int, double New: boolean, char The String Class Type Conversion Expressions Assignment
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 informationChapter 2 Primitive Data Types and Operations
Chapter 2 Primitive Data Types and Operations 2.1 Introduction You will be introduced to Java primitive data types and related subjects, such as variables constants, data types, operators, and expressions.
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 informationJAVA OPERATORS GENERAL
JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators
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 informationIntroduction to Java & Fundamental Data Types
Introduction to Java & Fundamental Data Types LECTURER: ATHENA TOUMBOURI How to Create a New Java Project in Eclipse Eclipse is one of the most popular development environments for Java, as it contains
More informationTable of Contents Date(s) Title/Topic Page #s. Abstraction
Table of Contents Date(s) Title/Topic Page #s 9/10 2.2 String Literals, 2.3 Variables and Assignment 34-35 Abstraction An abstraction hides (or suppresses) the right details at the right time An object
More informationCSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals
CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasketEnhanced { public static void main(string[]
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 informationComputer 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 informationC++ Basics. Lecture 2 COP 3014 Spring January 8, 2018
C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing
More informationEx: If you use a program to record sales, you will want to remember data:
Data Variables Programs need to remember values. Ex: If you use a program to record sales, you will want to remember data: A loaf of bread was sold to Sione Latu on 14/02/19 for T$1.00. Customer Name:
More informationJAVA Programming Concepts
JAVA Programming Concepts M. G. Abbas Malik Assistant Professor Faculty of Computing and Information Technology University of Jeddah, Jeddah, KSA mgmalik@uj.edu.sa Programming is the art of Problem Solving
More informationPeer Instruction 1. Elementary Programming
Peer Instruction 1 Elementary Programming 0 Which of the following variable declarations will not compile? Please select the single correct answer. A. int i = 778899; B. double x = 5.43212345; C. char
More informationBasic 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 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 information