Title. Java Just in Time. John Latham. November 5, November 5, 2018 Java Just in Time - John Latham Page 1(0/0)
|
|
- Marian Morrison
- 5 years ago
- Views:
Transcription
1 List of Slides 1 Title 2 Chapter 9: Consolidation of concepts so far 3 Chapter aims 4 Section 2: Java concepts 5 Aim 6 Java concepts 7 Type: long 8 Type: short 9 Type: byte 10 Type: char 11 Type: char: literal 12 Variable: char variable 13 Type: char: literal: escape sequences 14 Type: float 15 Java concepts 16 Example-class.java 0-0
2 20 Java concepts 21 Expression: arithmetic: remainder operator 22 Java concepts 23 Section 3: Program design concepts 24 Aim 25 Program design concepts 26 Program design concepts 28 Designing the variables 29 Designing the variables 30 Designing the variables 31 Designing the variables 32 Designing the variables 33 Designing the variables 34 Designing the variables 35 Designing the variables 36 Designing the variables 37 Designing the variables 38 Designing the variables 0-1
3 39 Designing the variables 40 Designing the variables 41 Designing the variables 42 Designing the variables 43 Designing the algorithm 44 Designing the algorithm 45 Designing the algorithm 46 Designing the algorithm 47 Designing the algorithm 49 Designing the algorithm 50 TimesTable.java 52 Designing the algorithm 53 Concepts covered in this chapter 0-2
4 Title Java Just in Time John Latham November 5, 2018 November 5, 2018 Java Just in Time - John Latham Page 1(0/0)
5 Chapter 9 Consolidation of concepts so far November 5, 2018 Java Just in Time - John Latham Page 2(0/0)
6 Chapter aims Consolidate concepts covered so far. opportunity to decide what you should reread. Introduce a few more simple concepts. Look specifically at process of designing programs mostly so far done via osmosis. November 5, 2018 Java Just in Time - John Latham Page 3(0/0)
7 Section 2 Java concepts November 5, 2018 Java Just in Time - John Latham Page 4(0/0)
8 Aim AIM: To consolidate and summarize the Java concepts introduced in the preceding chapters. We also introduce some more simple concepts which were not covered before, but which compliment those that were such as the float type. November 5, 2018 Java Just in Time - John Latham Page 5(0/0)
9 Java concepts Read chapter to review what already has been covered. Take time also to meet new concepts some of them will be used in later chapters. Java source code lexical details... Classes, methods, types, variables and layout... November 5, 2018 Java Just in Time - John Latham Page 6(0/0)
10 Type: long The type int uses four bytes, 32 binary digits. Gives range 2 31 through to is The type long represents long integers using eight bytes. Gives range 2 63 through to is A long literal has L on the end e.g. -15L, L. November 5, 2018 Java Just in Time - John Latham Page 7(0/0)
11 Type: short The type short represents short integers using two bytes. Gives range 2 15 through to is Useful when have huge number of integers lying in that range uses less space. November 5, 2018 Java Just in Time - John Latham Page 8(0/0)
12 Type: byte The type byte represents integers using one byte. Gives range 2 7 through to is 127. November 5, 2018 Java Just in Time - John Latham Page 9(0/0)
13 Type: char Characters are represented by type char. A char variable can store a single character. November 5, 2018 Java Just in Time - John Latham Page 10(0/0)
14 Type: char: literal A character literal is written using single quotes. E.g. J November 5, 2018 Java Just in Time - John Latham Page 11(0/0)
15 Variable: char variable Can have char variables, e.g. char firstletter = J ; November 5, 2018 Java Just in Time - John Latham Page 12(0/0)
16 Type: char: literal: escape sequences A character literal can have escape sequences same as for string literals. E.g. char backspace = \b ; char tab = \t ; char newline = \n ; char formfeed = \f ; char carriagereturn = \r ; char doublequote = \" ; char singlequote = \ ; char backslash = \\ ; November 5, 2018 Java Just in Time - John Latham Page 13(0/0)
17 Type: float The type float stores real numbers uses single precision floating point representation only four bytes per number The type double uses double precision far more accurate needs eight bytes per number. A float literal ends in f or F e.g. 0.0F, F, f November 5, 2018 Java Just in Time - John Latham Page 14(0/0)
18 Java concepts Typical single class program: November 5, 2018 Java Just in Time - John Latham Page 15(0/0)
19 Example-class.java 001: // Comments here to say what the program does. 002: // This may take several lines. 003: public class ProgramName 004: { 005: // Each class variable should have comments saying what it is used for. 006: private static int somevariable; 007: 008: // Variables can be initialized when they are declared. 009: private static double someothervariable = somevariable * 100.0; 010: 011: November 5, 2018 Java Just in Time - John Latham Page 16(0/0)
20 Example-class.java 012: // Each method should have comments saying what it does. 013: // If it does not return a result, we write the word void. 014: public static void somemethod(int aparameter) 015: { 016: // Local variables should also have a comment. 017: int alocalvariable; 018: 019:... Method instruction statements go here. 020: // Comments are used to help make tricky code readable. 021: : } // somemethod 023: 024: November 5, 2018 Java Just in Time - John Latham Page 17(0/0)
21 Example-class.java 025: // Methods which are only of use in this class/program should be private. 026: // If it returns a result, we state the type in the heading. 027: private static double someothermethod(boolean parameter1, int parameter2) 028: { 029: double alocalvariable; 030: : return something; 032: } // someothermethod 033: 034: November 5, 2018 Java Just in Time - John Latham Page 18(0/0)
22 Example-class.java 035: // The program always starts its execution at the main method. 036: // The parameters are the command line arguments of the program. 037: public static void main(string[] args) 038: { 039: : } // main 041: 042: } // class ProgramName November 5, 2018 Java Just in Time - John Latham Page 19(0/0)
23 Java concepts Statements... Expressions... November 5, 2018 Java Just in Time - John Latham Page 20(0/0)
24 Expression: arithmetic: remainder operator Another arithmetic operator remainder: % also known as modulo. Given two integer operands yields remainder after dividing first by second. E.g. public static boolean iseven(int number) { return number % 2 == 0; } // iseven November 5, 2018 Java Just in Time - John Latham Page 21(0/0)
25 Java concepts Errors... Standard classes... November 5, 2018 Java Just in Time - John Latham Page 22(0/0)
26 Section 3 Program design concepts November 5, 2018 Java Just in Time - John Latham Page 23(0/0)
27 Aim AIM: To look more formally at the process of designing an algorithm and writing a program. In particular, we look closely at designing variables. November 5, 2018 Java Just in Time - John Latham Page 24(0/0)
28 Program design concepts Seen lots of example programs, done coursework by osmosis you have begun to learn skill of programming. Now we formalize this a little: how do we write a program / method? Really: how do we write an algorithm? Guidelines not a recipe: November 5, 2018 Java Just in Time - John Latham Page 25(0/0)
29 Program design concepts 1. Understand the problem obviously you cannot possibly get the computer to solve it otherwise. (It is amazing how many people overlook this!) 2. Ask yourself how you would solve the problem if you were not going to program a computer. If you cannot answer this then almost certainly you will fail to get the computer to do it. 3. Consider whether the way you would do it is the way the computer should do it. Often it is, because we humans are actually very good at being lazy, and finding the best way to do something when we put our minds to it. On the other hand, sometimes the way a computer would do it is different because of the nature of computers compared with us they are very quick at doing mindless things. 4. Decide how the computer should do it, i.e. what is the basic method your algorithm will use. November 5, 2018 Java Just in Time - John Latham Page 26(0/0)
30 Program design concepts 5. Design the variables used in the algorithm, very carefully. We shall say more about this shortly. 6. Design the algorithm itself in pseudo code. If the previous step is done properly, this one will almost do itself. 7. Finally implement the algorithm in code this should be the easiest part if the previous steps have been followed carefully. November 5, 2018 Java Just in Time - John Latham Page 27(0/0)
31 Designing the variables A variable is just a named location your code can stick a value there (of appropriate type) and change it from time to time. November 5, 2018 Java Just in Time - John Latham Page 28(0/0)
32 Designing the variables No, No, NO, NOO, NOOOOO, NOOOOOOOOOOOOO!!!!!!!! Far too computer centric view to help us design. This is exactly what is wrong with many programs. November 5, 2018 Java Just in Time - John Latham Page 29(0/0)
33 Designing the variables Focus on meaning of data by designing variables get this wrong and our programs will not work be badly written hard to fix essentially useless! Classic mistake: recognise variable needed of certain type then quickly choose its name never carefully consider what it means with respect to problem Result: cryptic names buggy code. November 5, 2018 Java Just in Time - John Latham Page 30(0/0)
34 Designing the variables Java invites this attitude: you write type of variable before name! Resist!!!! We must really think about these the other way round. November 5, 2018 Java Just in Time - John Latham Page 31(0/0)
35 Designing the variables Example code, written by computer centric programmer. Assume getcurrenthumidity() and PRECIPITATION THRESHOLD boolean b; if (getcurrenthumidity() > PRECIPITATION_THRESHOLD) b = true;... else b = false; if (b == true) System.out.println("Take your umbrella!"); November 5, 2018 Java Just in Time - John Latham Page 32(0/0)
36 Designing the variables Is that code okay? Well it does work...maybe. Recall how naughty code like if (b == true) is? Terrible! November 5, 2018 Java Just in Time - John Latham Page 33(0/0)
37 Designing the variables Let s choose better name for boolean variable, b what does it really mean? boolean rainislikely; if (getcurrenthumidity() > PRECIPITATION_THRESHOLD) rainislikely = true;... else rainislikely = false; if (rainislikely == true) System.out.println("Take your umbrella!"); November 5, 2018 Java Just in Time - John Latham Page 34(0/0)
38 Designing the variables How often do you say? Do you think it will rain equals true? November 5, 2018 Java Just in Time - John Latham Page 35(0/0)
39 Designing the variables Do not need if else statement. boolean rainislikely = getcurrenthumidity() > PRECIPITATION_THRESHOLD; Do not need == true. if (rainislikely) System.out.println("Take your umbrella!"); Poor design led to poor style. November 5, 2018 Java Just in Time - John Latham Page 36(0/0)
40 Designing the variables Example: where it leads to buggy code we wish to count items here is pseudo code. int i = 1 while there are more items get an item i++ end-while output "There were " i " items" Coffee time: Whatiswrongwiththisdesignandhowshoulditbefixed? There are two obvious ways to fix it. Which is best? November 5, 2018 Java Just in Time - John Latham Page 37(0/0)
41 Designing the variables Think carefully what i really is... number of items we have had so far. int itemcountsofar = 1 while there are more items get an item itemcountsofar++ end-while output "There were " itemcountsofar " items" Ah ha! First line is a lie that is where error is. November 5, 2018 Java Just in Time - John Latham Page 38(0/0)
42 Designing the variables Or, i is number of next item to be obtained. int nextitemnumber = 1 while there are more items get an item nextitemnumber++ end-while output "There were " nextitemnumber " items" Now last line is a lie that is where error is! November 5, 2018 Java Just in Time - John Latham Page 39(0/0)
43 Designing the variables i was an ambiguous name because of lack of design about what it really means was treated with different interpretation in different parts of design. Which interpretation is best? itemcountsofar or nextitemnumber? subjective but, always a count of items so far, not always a next item... November 5, 2018 Java Just in Time - John Latham Page 40(0/0)
44 Designing the variables Treat variables with respect design them carefully. They represent identifiable entities in the problem. If cannot fully and precisely describe meaning in one sentence then probably is a bad variable think again! That sentence will be your comment for the variable. Condense it to a few words to make variable name. Then you can identify its type! November 5, 2018 Java Just in Time - John Latham Page 41(0/0)
45 Designing the variables If you design variables well then algorithm code almost writes itself just ensure value of every variable reflects its meaning at all times you cannot have a bug! Well, you might make a mistake but if you do, it will be easy to spot. Plus, code is easier to read and maintain too! November 5, 2018 Java Just in Time - John Latham Page 42(0/0)
46 Designing the algorithm Express algorithm at high level of abstraction. Add more detail lower abstraction level. Until low enough that implementation in Java straightforward. E.g. our first example was MinimumBitWidth: get numberofvalues from command line noofbits = 0 while noofbits is too small increment noofbits output noofbits November 5, 2018 Java Just in Time - John Latham Page 43(0/0)
47 Designing the algorithm Then added more detail: numberofvalues = args[0] noofbits = 0 noofbits while 2 noofbits++ s.o.p noofbits < numberofvalues Close enough to Java so easy to implement. November 5, 2018 Java Just in Time - John Latham Page 44(0/0)
48 Designing the algorithm Next example was PiEstimation: obtain tolerance from command line set up previousestimate as value from no terms set up latestestimate as value from one term while previousestimate is not within tolerance of latestestimate previousestimate = latestestimate add next term to latestestimate end-while print out latestestimate print out the number of terms used print out the standard known value of Pi for comparison November 5, 2018 Java Just in Time - John Latham Page 45(0/0)
49 Designing the algorithm We lowered level of abstraction: double tolerance = args[0] double previousestimate = 0 double latestestimate = 4 int termcount = 1 while previousestimate is not within tolerance of latestestimate previousestimate = latestestimate add next term to latestestimate termcount++ end-while s.o.p latestestimate s.o.p termcount s.o.p the standard known value of Pi for comparison November 5, 2018 Java Just in Time - John Latham Page 46(0/0)
50 Designing the algorithm And again: double tolerance = args[0] double previousestimate = 0 double latestestimate = 4 int termcount = 1 int nextdenominator = 3 int nextnumeratorsign = -1 while Math.abs(latestEstimate - previousestimate) > tolerance previousestimate = latestestimate latestestimate += nextnumeratorsign * 4 / nextdenominator termcount++ nextnumeratorsign *= -1 nextdenominator += 2 end-while November 5, 2018 Java Just in Time - John Latham Page 47(0/0)
51 Designing the algorithm s.o.p latestestimate s.o.p termcount s.o.p Math.PI November 5, 2018 Java Just in Time - John Latham Page 48(0/0)
52 Designing the algorithm Another example was TimesTable: print the box top line print column headings print headings underline for row = 1 to 10 print a row print the box bottom line Later we implemented this using separate methods. Steps in early abstract designs often make good choice for methods: November 5, 2018 Java Just in Time - John Latham Page 49(0/0)
53 TimesTable.java 001: // Program to print out a neat multiplication table. 002: public class TimesTable 003: { 004: // The size of the table -- the number of rows and columns. 005: private static int tablesize = 12; 006: 007: 008: // The main method implements the top level structure of the table. 009: public static void main(string[] args) 010: { 011: // Top line. 012: printline(); 013: 014: // Column headings. 015: printcolumnheadings(); November 5, 2018 Java Just in Time - John Latham Page 50(0/0)
54 TimesTable.java 016: 017: // Underline headings. 018: printline(); 019: 020: // Now the rows. 021: for (int row = 1; row <= tablesize; row++) 022: printrow(row); 023: 024: // Bottom line. 025: printline(); 026: } // main : } // class TimesTable November 5, 2018 Java Just in Time - John Latham Page 51(0/0)
55 Designing the algorithm Generalize algorithm design process: 1. Identify main steps of algorithm. 2. Express algorithm in terms of main steps. 3. Separately expand on each step using same process i.e. identify its main steps... Sometimes called top down stepwise refinement. November 5, 2018 Java Just in Time - John Latham Page 52(0/0)
56 Concepts covered in this chapter Each book chapter ends with a list of concepts covered in it. Each concept has with it a self-test question, and a page reference to where it was covered. Please use these to check your understanding before we start the next chapter. November 5, 2018 Java Just in Time - John Latham Page 53(0/0)
20 Minimum bit width 21 Minimum bit width 22 Design: pseudo code 24 Minimum bit width 25 Minimum bit width 26 Standard API: Math: pow() 27 Minimum bit
List of Slides 1 Title 2 Chapter 5: Repeated execution 3 Chapter aims 4 Section 2: Example:Minimum tank size 5 Aim 6 Minimum tank size 7 Execution: repeated execution 8 Statement: assignment statement:
More information17 Statement: assignment statement: assigning an expression value 18 Age next year 19 Type: String: conversion: from int 21 Age next year 22 The full
List of Slides 1 Title 2 Chapter 3: Types, variables and expressions 3 Chapter aims 4 Section 2: Example:Age next year 5 Aim 6 Design: hard coding 7 Age next year 8 Type 9 Type: int 10 Variable 11 Variable:
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today: Java basics: Compilation vs Interpretation Program structure Statements Values Variables Types Operators and Expressions
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 information3. Java - Language Constructs I
Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks
More informationList of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs ar
List of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs are divided into classes 7 Class: public class 8 Class:
More informationChapter 6 Primitive types
Chapter 6 Primitive types Lesson page 6-1. Primitive types Question 1. There are an infinite number of integers, so it would be too ineffient to have a type integer that would contain all of them. Question
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 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 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 informationCS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output
CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output Last revised January 12, 2006 Objectives: 1. To introduce arithmetic operators and expressions 2. To introduce variables
More information26 Age history with a separate method 27 Method: void methods 28 Age history with a separate method 29 Age history with a separate method 33 Trying it
List of Slides 1 Title 2 Chapter 8: Separate methods and logical operators 3 Chapter aims 4 Section 2: Example:Age history with two people 5 Aim 6 Age history with two people 11 Trying it 12 Coursework:
More information17 Hello world 18 Type: String: literal 19 Standard API: System: out.println() 20 Hello world 21 Statement 22 Statement: simple statements are ended w
List of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs are divided into classes 7 Class: public class 8 Class:
More informationCMPT 125: Lecture 3 Data and Expressions
CMPT 125: Lecture 3 Data and Expressions Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 1 Character Strings A character string is an object in Java,
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 informationCOMP-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 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 informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,
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 informationCPS122 Lecture: From Python to Java
Objectives: CPS122 Lecture: From Python to Java last revised January 7, 2013 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.
More informationAn overview of Java, Data types and variables
An overview of Java, Data types and variables Lecture 2 from (UNIT IV) Prepared by Mrs. K.M. Sanghavi 1 2 Hello World // HelloWorld.java: Hello World program import java.lang.*; class HelloWorld { public
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 informationJava Bytecode (binary file)
Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.
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 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 information1 Introduction Java, the beginning Java Virtual Machine A First Program BlueJ Raspberry Pi...
Contents 1 Introduction 3 1.1 Java, the beginning.......................... 3 1.2 Java Virtual Machine........................ 4 1.3 A First Program........................... 4 1.4 BlueJ.................................
More informationCS11 Java. Fall Lecture 1
CS11 Java Fall 2006-2007 Lecture 1 Welcome! 8 Lectures Slides posted on CS11 website http://www.cs.caltech.edu/courses/cs11 7-8 Lab Assignments Made available on Mondays Due one week later Monday, 12 noon
More informationControl Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003
Control Flow COMS W1007 Introduction to Computer Science Christopher Conway 3 June 2003 Overflow from Last Time: Why Types? Assembly code is typeless. You can take any 32 bits in memory, say this is an
More informationSchool of Computer Science CPS109 Course Notes 5 Alexander Ferworn Updated Fall 15
Table of Contents 1 INTRODUCTION... 1 2 IF... 1 2.1 BOOLEAN EXPRESSIONS... 3 2.2 BLOCKS... 3 2.3 IF-ELSE... 4 2.4 NESTING... 5 3 SWITCH (SOMETIMES KNOWN AS CASE )... 6 3.1 A BIT ABOUT BREAK... 7 4 CONDITIONAL
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 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 informationAbout this exam review
Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review
More informationBASIC 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 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 informationRoom 3P16 Telephone: extension ~irjohnson/uqc146s1.html
UQC146S1 Introductory Image Processing in C Ian Johnson Room 3P16 Telephone: extension 3167 Email: Ian.Johnson@uwe.ac.uk http://www.csm.uwe.ac.uk/ ~irjohnson/uqc146s1.html Ian Johnson 1 UQC146S1 What is
More information4. Inputting data or messages to a function is called passing data to the function.
Test Bank for A First Book of ANSI C 4th Edition by Bronson Link full download test bank: http://testbankcollection.com/download/test-bank-for-a-first-book-of-ansi-c-4th-edition -by-bronson/ Link full
More informationCOMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods
COMP-202 Unit 2: Java Basics CONTENTS: Using Expressions and Variables Types Strings Methods Assignment 1 Assignment 1 posted on WebCt and course website. It is due May 18th st at 23:30 Worth 6% Part programming,
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 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 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 information1007 Imperative Programming Part II
Agenda 1007 Imperative Programming Part II We ve seen the basic ideas of sequence, iteration and selection. Now let s look at what else we need to start writing useful programs. Details now start to be
More informationChapter 3: Operators, Expressions and Type Conversion
101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To
More informationCPS122 Lecture: From Python to Java last revised January 4, Objectives:
Objectives: CPS122 Lecture: From Python to Java last revised January 4, 2017 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.
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 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 informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
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 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 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 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 informationFeatures of C. Portable Procedural / Modular Structured Language Statically typed Middle level language
1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC
More informationOverview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O
Overview of C Basic Data Types Constants Variables Identifiers Keywords Basic I/O NOTE: There are six classes of tokens: identifiers, keywords, constants, string literals, operators, and other separators.
More informationVisual C# Instructor s Manual Table of Contents
Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms
More informationProgram Elements -- Introduction
Program Elements -- Introduction We can now examine the core elements of programming Chapter 3 focuses on: data types variable declaration and use operators and expressions decisions and loops input and
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 informationComputer System and programming in C
1 Basic Data Types Integral Types Integers are stored in various sizes. They can be signed or unsigned. Example Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign bit. If the sign
More informationJava Basic Datatypees
Basic Datatypees Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in the memory. Based on the data type of a variable,
More informationCS112 Lecture: Working with Numbers
CS112 Lecture: Working with Numbers Last revised January 30, 2008 Objectives: 1. To introduce arithmetic operators and expressions 2. To expand on accessor methods 3. To expand on variables, declarations
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 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 informationcis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1
topics: introduction to java, part 1 cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 cis20.1-fall2007-sklar-leci.2 1 Java. Java is an object-oriented language: it is
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 informationProfessor Peter Cheung EEE, Imperial College
1/1 1/2 Professor Peter Cheung EEE, Imperial College In this lecture, we take an overview of the course, and briefly review the programming language. The rough guide is not very complete. You should use
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 informationTitle. Java Just in Time. John Latham. October 25, October 25, 2017 Java Just in Time - John Latham Page 1(0/0)
List of Slides 1 Title 2 Chapter 6: Control statements nested in loops 3 Chapter aims 4 Section 2: Example:Film certificate age checking the whole queue 5 Aim 6 Statement: statements can be nested within
More information1.00 Lecture 4. Promotion
1.00 Lecture 4 Data Types, Operators Reading for next time: Big Java: sections 6.1-6.4 Promotion increasing capacity Data Type Allowed Promotions double None float double long float,double int long,float,double
More informationAlgebraic Specifications
Object-Oriented Design Lecture 2 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 11, 2007 Algebraic Specifications Last time I said a word about the abstraction barrier, separating the clients from the implementors.
More informationMicroprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)
Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming) Learning any imperative programming language involves mastering a number of common concepts: Variables: declaration/definition
More informationProgramming for Engineers Introduction to C
Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines
More informationTOPIC 2 INTRODUCTION TO JAVA AND DR JAVA
1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared
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 informationThese are notes for the third lecture; if statements and loops.
These are notes for the third lecture; if statements and loops. 1 Yeah, this is going to be the second slide in a lot of lectures. 2 - Dominant language for desktop application development - Most modern
More informationCOMP-202 Unit 2: Java Basics. CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables
COMP-202 Unit 2: Java Basics CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables Assignment 1 Assignment 1 posted on WebCt and course website.
More informationInformation Science 1
Topics covered Information Science 1 Terms and concepts from Week 8 Simple calculations Documenting programs Simple Calcula,ons Expressions Arithmetic operators and arithmetic operator precedence Mixed-type
More information\n is used in a string to indicate the newline character. An expression produces data. The simplest expression
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More information1 Lexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler
More informationCSE 1001 Fundamentals of Software Development 1. Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018
CSE 1001 Fundamentals of Software Development 1 Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018 Identifiers, Variables and Data Types Reserved Words Identifiers in C Variables and Values
More informationProgramming in C++ 4. The lexical basis of C++
Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++
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 informationCS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation
CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;
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 informationLanguage Reference Manual
ALACS Language Reference Manual Manager: Gabriel Lopez (gal2129) Language Guru: Gabriel Kramer-Garcia (glk2110) System Architect: Candace Johnson (crj2121) Tester: Terence Jacobs (tj2316) Table of Contents
More informationprintf( Please enter another number: ); scanf( %d, &num2);
CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful
More information2 rd class Department of Programming. OOP with Java Programming
1. Structured Programming and Object-Oriented Programming During the 1970s and into the 80s, the primary software engineering methodology was structured programming. The structured programming approach
More informationc) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.
2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C
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 informationage = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s
Intro to Python Python Getting increasingly more common Designed to have intuitive and lightweight syntax In this class, we will be using Python 3.x Python 2.x is still very popular, and the differences
More informationCS 142 Style Guide Grading and Details
CS 142 Style Guide Grading and Details In the English language, there are many different ways to convey a message or idea: some ways are acceptable, whereas others are not. Similarly, there are acceptable
More informationCS102: Variables and Expressions
CS102: Variables and Expressions The topic of variables is one of the most important in C or any other high-level programming language. We will start with a simple example: int x; printf("the value of
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 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 informationThese are reserved words of the C language. For example int, float, if, else, for, while etc.
Tokens in C Keywords These are reserved words of the C language. For example int, float, if, else, for, while etc. Identifiers An Identifier is a sequence of letters and digits, but must start with a letter.
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 informationConditionals, Loops, and Style
Conditionals, Loops, and Style yes x > y? no max = x; max = y; http://xkcd.com/292/ Fundamentals of Computer Science Keith Vertanen Copyright 2013 Control flow thus far public class ArgsExample public
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 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 informationA First Program - Greeting.cpp
C++ Basics A First Program - Greeting.cpp Preprocessor directives Function named main() indicates start of program // Program: Display greetings #include using namespace std; int main() { cout
More informationCHAPTER 7 ARRAYS: SETS OF SIMILAR DATA ITEMS
CHAPTER 7 ARRAYS: SETS OF SIMILAR DATA ITEMS Computers process information and usually they need to process masses of information. In previous chapters we have studied programs that contain a few variables
More informationCOMP-202: Foundations of Programming. Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015
COMP-202: Foundations of Programming Lecture 2: Variables, and Data Types Sandeep Manjanna, Summer 2015 Announcements Midterm Exams on 4 th of June (12:35 14:35) Room allocation will be announced soon
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 information