CT 229 Java Syntax Continued
|
|
- Owen Griffin
- 6 years ago
- Views:
Transcription
1 CT 229 Java Syntax Continued 06/10/2006 CT229
2 Lab Assignments Due Date for current lab assignment : Oct 8 th Before submission make sure that the name of each.java file matches the name given in the assignment sheet!!!! Remember: Electronic or edward.scully@nuigalway.ie subject: CT229 NEW LAB ASSIGNMENT FOR NEXT WEEK!! 06/10/2006 CT229 1
3 Tutorials Tutorial Problem Sheet available online the week of the tutorial. 06/10/2006 CT229 2
4 Review of Last Week Precedence: Determines the order in which operators act in an expression with more than one operator. Associativity Rule: Specifies the correct order of evaluation when operations are of equal precedence 06/10/2006 CT229 3
5 Precedence & Associativity Table Prec. Operators Associativity 1 () []. Left to right 2! ~ (unary) -(unary) Right to left ~(unary) (type-cast) 3 * / % Left to right Left to right 5 << >> >>> Left to right 6 < <= > >= instanceof Left to right 7 ==!= Left to right 8 & Left to right 9 ^ Left to right 10 Left to right 11 && Left to right 12 Left to right 13?: Right to left 14 = += -= *= /= %= &= ^= = <<= >>= Right to left 06/10/2006 CT229 4
6 Review of Last Week if statement if Statements if (condition1) action_if_condition1_true; else if (condition2) action_if_condition1_true; else action_if_all_conditions_false; 06/10/2006 CT229 5
7 Review of Last Week switch Statement int choice; /* user enters 1, 2, 3, or 4 for choice */ switch (choice) case 1: doactionone(); // done if choice == 1 break; // don't do next stmt case 2: doactiontwo(); // if choice == 2 break; case 3: case 4: doactionthreefour(); // if choice == 2,3,4 break; default: displayerror(); // all other cases 06/10/2006 CT229 6
8 Repetition: while while: Repeat a statement/block while a condition is true Useful when we don't know in advance how many times to repeat (for used more often when we do know) Format while (condition) action; 06/10/2006 CT229 7
9 Repetition - While int count = 1; while (count < 5) System.out.println("Count is: " + count); count++; Count is: 1 Count is: 2 Count is: 3 Count is: 4 06/10/2006 CT229 8
10 Repetition - do/while do/while: Like while, but condition tested after action first done Action guaranteed to be executed at least once Useful when action initialises variable used in condition Format: do action; while (condition); 06/10/2006 CT229 9
11 Repetition do/while int count = 1; do System.out.println("Count is: " + count); count++; while (count < 5); Count is: 1 Count is: 2 Count is: 3 Count is: 4 06/10/2006 CT229 10
12 do/while example The following program should ask the user for a number that is 1 and 10. If the user enters a number within the range then the user is asked to enter a another number If the user enters a number outside of that range then exit the program 06/10/2006 CT229 11
13 do/while Example int number; do String numberstr = JOptionPane.showInputDialog("Please enter a number between 1 and 10"); number = Integer.parseInt(numberStr); while ( (number >0) && (number <11) ); JOptionPane.showMessageDialog(null, "Exiting Program"); 06/10/2006 CT229 12
14 while loop version of example int number; String numberstr = JOptionPane.showInputDialog("Please enter a number between 1 and 10"); number = Integer.parseInt(numberStr); while ((number >0) && (number <11)) numberstr = JOptionPane.showInputDialog("Please enter a number between 1 and 10"); number = Integer.parseInt(numberStr); JOptionPane.showMessageDialog(null, "Exiting Program"); 06/10/2006 CT229 13
15 Repetition: for Used to repeat block of code specified number of times Useful when number of repetitions known E.g. print 10 lines for (i = 0 ; i < 10 ; i++) System.out.println("Line " + i); 1: Initialise 2: Test 3: Increment Initialise control variable: once, at very start of loop Test: every time, before executing loop body Increment: every time, after loop body, before next test 06/10/2006 CT229 14
16 For: Notes Initialise Section: Can declare the control variable: for (int x=5; x<10; x++) Scope of variable is until end of loop Test Section: If testing (variable == value) ensure variable does not miss the exact value, particularly with float/double Using >= or <= may be safer Increment Section: Can increment, decrement, add 7, whatever For clarity, use combined assignment operator (x += 7) 06/10/2006 CT229 15
17 for loop Examples for (int i = 1; i < 10; i+=2) System.out.println( i = " +i); i = 1 i = 3 i = 5 i = 7 i = 9 for (int i = 1; i < 10; i+=3) System.out.println( i = " +i); i = 1 i = 4 i = 7 06/10/2006 CT229 16
18 for loop Examples for (int i = 1; i < 10; i*=2) System.out.println( i = " +i); i = 1 i = 2 i = 4 i = 8 for (int i = 1; i < 10; i*=3) System.out.println( i = " +i); i = 1 i = 3 i = 9 06/10/2006 CT229 17
19 for loop Examples for (int i = 10; i > 0; i -=2) System.out.println("i = " +i); i = 10 i = 8 i = 6 i = 4 i = 2 for (int i = 10; i > 0; i-=3) System.out.println("i = " +i); i = 10 i = 7 i = 4 i = 1 06/10/2006 CT229 18
20 Nested For Loops Placing one for loop inside another Example for (int i = 1; i < 5; i++) for (int j = 1; j < 3; j++) System.out.print((i*j)+" "); System.out.println(); /10/2006 CT229 19
21 CT 229 Java Methods 06/10/2006 CT229
22 Methods: Introduction Methods are always members of a class So far, have just had main method in program public class Many pre-defined methods in Java API (e.g. Math methods) Cannot define a method inside another method Definition consists of: Method type Return Type Method Name List of Parameters To call (invoke) method: Write name of method, with list of arguments (data) to pass to method If the method returns a value, a it can be used as part of an expression 06/10/2006 CT229 21
23 Simple Method import javax.swing.joptionpane; public class WelcomeMethod public static void main(string[] args) welcomemessage(); public static void welcomemessage() JOptionPane.showMessageDialog(null,"Welcome to the program"); 06/10/2006 CT229 22
24 Defining a Method Format: method-type return-type method-name (parameter-list) declarations and statements: body of method method-type: public/private, static (later topic) return-type: data type of result returned by method, or void if the method does not return a result method-name: any valid identifier (like variable name) parameter-list: next slide 06/10/2006 CT229 23
25 A Method with Parameters import javax.swing.joptionpane; public class parametermethod public static void main(string[] args) String personsname = "John"; int personsage = 25; printage(personsname, personsage); public static void printage(string name, int age) JOptionPane.showMessageDialog(null, "The age of " + name + " is " + age); 06/10/2006 CT229 24
26 Parameters Arguments in call printage(personsname, personsage); Map to parameters in method public static void printage(string name, int age) JOptionPane.showMessageDialog(null, "The age of " + name + " is " + age); This mapping is based on position Each argument in call must match corresponding parameter in method definition Arguments and parameters must have matching number, order, type 06/10/2006 CT229 25
27 Defining a Method Return value: If not void, method must have a statement return expression; If void, method returns at closing "" 06/10/2006 CT229 26
28 Returning a (String) Value from a Method import javax.swing.joptionpane; public class returningmethod public static void main(string[] args) String name; name = askusername(); JOptionPane.showMessageDialog(null, Username is +name); private static String askusername() String username = JOptionPane.showInputDialog("Please enter your name"); return username; 06/10/2006 CT229 27
29 Returning a (boolean) Value from a Method // Checks if parameter is an even number public static boolean is_even (int x) int ans = x % 2; if (ans == 0) return true; else return false; 06/10/2006 CT229 28
30 Returning a (boolean) Value from a Method public static void main(string args[]) boolean result; String numstr = JOptionPane.showInputDialog( Enter a number ); int num = Integer.parseInt(numStr); result = is_even(num); if (result) JOptionPane.showMessageDialog(null, even ); else JOptionPane.showMessageDialog(null, odd ); 06/10/2006 CT229 29
31 Simple Example (3) function name result = is_even(num); value of the variable in the function s return statement gets copied here argument s value gets copied to corresponding parameter in the function Sample scenario Assume num has the value 17 When is_even is called, 17 gets copied to x ans = (17 % 2) = 1 return statement sends back the value false 06/10/2006 CT229 30
32 Math Class Methods in Java must be contained in a class Mathematical methods are in class Math, in package java.lang Supports common mathematical calculations java.lang.math example Calculate the square root of 49.0: answer = Math.sqrt(49.0); Method sqrt belongs to class Math Dot (.) allows access to method sqrt The argument 49.0 is located inside parentheses Returns 7.0, which is used in assignment to answer 06/10/2006 CT229 31
33 Some Math Class Methods Method Description Example abs(x) absolute value of x (this method also has float, int and long versions) abs( 23.7 ) is 23.7 abs( 0.0 ) is 0.0 abs( ) is 23.7 ceil(x) rounds x to the smallest integer not less than x ceil( 9.2 ) is 10.0 ceil( -9.8 ) is -9.0 cos(x) trigonometric cosine of x (x is in radians) cos( 0.0 ) is 1.0 exp(x) exponential method ex exp( 1.0 ) is exp( 2.0 ) is floor(x) rounds x to the largest integer not greater than x floor( 9.2 ) is 9.0 floor( -9.8 ) is log(x) natural logarithm of x (base e) log( Math.E ) is 1.0 log( Math.E * Math.E ) is 2.0 max( 2.3, 12.7 ) is 12.7 max( -2.3, ) is -2.3 min( 2.3, 12.7 ) is 2.3 min( -2.3, ) is max(x,y) larger value of x and y (this method also has float, int and long versions) min(x,y) smaller value of x and y (this method also has float, int and long versions) pow(x,y) x raised to the power y (xy) pow( 2.0, 7.0 ) is pow( 9.0, 0.5 ) is 3.0 sin(x) trigonometric sine of x (x is in radians) sin( 0.0 ) is 0.0 sqrt(x) square root of x sqrt( ) is 30.0 sqrt( 9.0 ) is 3.0 tan(x) trigonometric tangent of x (x is in radians) tan( 0.0 ) is /10/2006 CT229 32
34 Some More Examples From course website: WagesMethod.java: Wages.java re-written with a method to calculate total 06/10/2006 CT229 33
35 Scope and Methods Data Area When a method is called, space is allocated for storage of its data: Formal Parameters Local Variables This data is lost when the method terminates Local variables cannot be accessed outside method but method can return a value Example demonstrating scoping issues: ScopeExample.java Multiple variables called x with different scopes 06/10/2006 CT229 34
CT 229 Java Syntax Continued
CT 229 Java Syntax Continued 29/09/2006 CT229 Lab Assignments One Week Extension for Lab Assignment 1. Due Date: Oct 8 th Before submission make sure that the name of each.java file matches the name given
More information6-1 (Function). (Function) !*+!"#!, Function Description Example. natural logarithm of x (base e) rounds x to smallest integer not less than x
(Function) -1.1 Math Library Function!"#! $%&!'(#) preprocessor directive #include !*+!"#!, Function Description Example sqrt(x) square root of x sqrt(900.0) is 30.0 sqrt(9.0) is 3.0 exp(x) log(x)
More informationwww.thestudycampus.com Methods Let s imagine an automobile factory. When an automobile is manufactured, it is not made from basic raw materials; it is put together from previously manufactured parts. Some
More informationMethods (Deitel chapter 6)
1 Plan 2 Methods (Deitel chapter ) Introduction Program Modules in Java Math-Class Methods Method Declarations Argument Promotion Java API Packages Random-Number Generation Scope of Declarations Methods
More informationMethods (Deitel chapter 6)
Methods (Deitel chapter 6) 1 Plan 2 Introduction Program Modules in Java Math-Class Methods Method Declarations Argument Promotion Java API Packages Random-Number Generation Scope of Declarations Methods
More informationMethods CSC 121 Fall 2014 Howard Rosenthal
Methods CSC 121 Fall 2014 Howard Rosenthal Lesson Goals Understand what a method is in Java Understand Java s Math Class Learn the syntax of method construction Learn both void methods and methods that
More informationPython Lists: Example 1: >>> items=["apple", "orange",100,25.5] >>> items[0] 'apple' >>> 3*items[:2]
Python Lists: Lists are Python's compound data types. A list contains items separated by commas and enclosed within square brackets ([]). All the items belonging to a list can be of different data type.
More informationMethods CSC 121 Fall 2016 Howard Rosenthal
Methods CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand what a method is in Java Understand Java s Math Class and how to use it Learn the syntax of method construction Learn both void methods
More informationLesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University
Lesson #3 Variables, Operators, and Expressions Variables We already know the three main types of variables in C: int, char, and double. There is also the float type which is similar to double with only
More informationChapter 4: Basic C Operators
Chapter 4: Basic C Operators In this chapter, you will learn about: Arithmetic operators Unary operators Binary operators Assignment operators Equalities and relational operators Logical operators Conditional
More informationMethods CSC 121 Spring 2017 Howard Rosenthal
Methods CSC 121 Spring 2017 Howard Rosenthal Lesson Goals Understand what a method is in Java Understand Java s Math Class and how to use it Learn the syntax of method construction Learn both void methods
More informationC++ Programming Lecture 11 Functions Part I
C++ Programming Lecture 11 Functions Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department Introduction Till now we have learned the basic concepts of C++. All the programs
More informationMethods: A Deeper Look
1 2 7 Methods: A Deeper Look OBJECTIVES In this chapter you will learn: How static methods and variables are associated with an entire class rather than specific instances of the class. How to use random-number
More informationCSI31 Lecture 5. Topics: 3.1 Numeric Data Types 3.2 Using the Math Library 3.3 Accumulating Results: Factorial
CSI31 Lecture 5 Topics: 3.1 Numeric Data Types 3.2 Using the Math Library 3.3 Accumulating Results: Factorial 1 3.1 Numberic Data Types When computers were first developed, they were seen primarily as
More informationVariable and Data Type 2
The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Intro. To Computers (LNGG 1003) Lab 3 Variable and Data Type 2 Eng. Ibraheem Lubbad March 2, 2017 Python Lists: Lists
More informationFundamentals of Programming & Procedural Programming
Universität Duisburg-Essen PRACTICAL TRAINING TO THE LECTURE Fundamentals of Programming & Procedural Programming Session Eight: Math Functions, Linked Lists, and Binary Trees Name: First Name: Tutor:
More informationIntroduction to Programming
Introduction to Programming session 9 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2010 These slides are created using Deitel s slides Sahrif University of Technology Outlines
More informationChapter 3. Computer Science & Engineering 155E Computer Science I: Systems Engineering Focus. Existing Information.
Chapter 3 Computer Science & Engineering 155E Computer Science I: Systems Engineering Focus Lecture 03 - Introduction To Functions Christopher M. Bourke cbourke@cse.unl.edu 3.1 Building Programs from Existing
More informationIntrinsic Functions Outline
Intrinsic Functions Outline 1. Intrinsic Functions Outline 2. Functions in Mathematics 3. Functions in Fortran 90 4. A Quick Look at ABS 5. Intrinsic Functions in Fortran 90 6. Math: Domain Range 7. Programming:
More informationFunction Example. Function Definition. C Programming. Syntax. A small program(subroutine) that performs a particular task. Modular programming design
What is a Function? C Programming Lecture 8-1 : Function (Basic) A small program(subroutine) that performs a particular task Input : parameter / argument Perform what? : function body Output t : return
More informationC++, How to Program. Spring 2016 CISC1600 Yanjun Li 1
Chapter 6 Function C++, How to Program Deitel & Deitel Spring 2016 CISC1600 Yanjun Li 1 Function A function is a collection of statements that performs a specific task - a single, well-defined task. Divide
More informationComputer Science & Engineering 150A Problem Solving Using Computers
Computer Science & Engineering 150A Problem Solving Using Computers Lecture 03 - Stephen Scott (Adapted from Christopher M. Bourke) 1 / 41 Fall 2009 Chapter 3 3.1 Building Programs from Existing Information
More informationC Functions. 5.2 Program Modules in C
1 5 C Functions 5.2 Program Modules in C 2 Functions Modules in C Programs combine user-defined functions with library functions - C standard library has a wide variety of functions Function calls Invoking
More informationFall Semester (081) Dr. El-Sayed El-Alfy Computer Science Department King Fahd University of Petroleum and Minerals
INTERNET PROTOCOLS AND CLIENT-SERVER PROGRAMMING Client SWE344 request Internet response Fall Semester 2008-2009 (081) Server Module 2.1: C# Programming Essentials (Part 1) Dr. El-Sayed El-Alfy Computer
More informationComputer Science & Engineering 150A Problem Solving Using Computers. Chapter 3. Existing Information. Notes. Notes. Notes. Lecture 03 - Functions
Computer Science & Engineering 150A Problem Solving Using Computers Lecture 03 - Functions Stephen Scott (Adapted from Christopher M. Bourke) Fall 2009 1 / 1 cbourke@cse.unl.edu Chapter 3 3.1 Building
More informationSequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;
Control Statements Control Statements All programs could be written in terms of only one of three control structures: Sequence Structure Selection Structure Repetition Structure Sequence structure The
More informationIntroduction to Programming
Introduction to Programming Department of Computer Science and Information Systems Tingting Han (afternoon), Steve Maybank (evening) tingting@dcs.bbk.ac.uk sjmaybank@dcs.bbk.ac.uk Autumn 2017 Week 4: More
More informationFunctions. Systems Programming Concepts
Functions Systems Programming Concepts Functions Simple Function Example Function Prototype and Declaration Math Library Functions Function Definition Header Files Random Number Generator Call by Value
More informationMaths Functions User Manual
Professional Electronics for Automotive and Motorsport 6 Repton Close Basildon Essex SS13 1LE United Kingdom +44 (0) 1268 904124 info@liferacing.com www.liferacing.com Maths Functions User Manual Document
More informationBil 104 Intiroduction To Scientific And Engineering Computing. Lecture 5. Playing with Data Modifiers and Math Functions Getting Controls
Readin from and Writint to Standart I/O BIL104E: Introduction to Scientific and Engineering Computing Lecture 5 Playing with Data Modifiers and Math Functions Getting Controls Pointers What Is a Pointer?
More informationIntroduction to Engineering gii
25.108 Introduction to Engineering gii Dr. Jay Weitzen Lecture Notes I: Introduction to Matlab from Gilat Book MATLAB - Lecture # 1 Starting with MATLAB / Chapter 1 Topics Covered: 1. Introduction. 2.
More informationMYSQL NUMERIC FUNCTIONS
MYSQL NUMERIC FUNCTIONS http://www.tutorialspoint.com/mysql/mysql-numeric-functions.htm Copyright tutorialspoint.com MySQL numeric functions are used primarily for numeric manipulation and/or mathematical
More informationOperators and Expression. Dr Muhamad Zaini Yunos JKBR, FKMP
Operators and Expression Dr Muhamad Zaini Yunos JKBR, FKMP Arithmetic operators Unary operators Relational operators Logical operators Assignment operators Conditional operators Comma operators Operators
More informationCT 229. Java Syntax 26/09/2006 CT229
CT 229 Java Syntax 26/09/2006 CT229 Lab Assignments Assignment Due Date: Oct 1 st Before submission make sure that the name of each.java file matches the name given in the assignment sheet!!!! Remember:
More informationC++ Overview. Chapter 1. Chapter 2
C++ Overview Chapter 1 Note: All commands you type (including the Myro commands listed elsewhere) are essentially C++ commands. Later, in this section we will list those commands that are a part of the
More information1001ICT Introduction To Programming Lecture Notes
1001ICT Introduction To Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 1, 2015 1 M Environment console M.1 Purpose This environment supports programming
More informationThe Math Class. Using various math class methods. Formatting the values.
The Math Class Using various math class methods. Formatting the values. The Math class is used for mathematical operations; in our case some of its functions will be used. In order to use the Math class,
More informationThe Number object. to set specific number types (like integer, short, In JavaScript all numbers are 64bit floating point
Internet t Software Technologies JavaScript part three IMCNE A.A. 2008/09 Gabriele Cecchetti The Number object The JavaScript Number object does not allow you to set specific number types (like integer,
More informationWeek 2: Console I/O and Operators Arithmetic Operators. Integer Division. Arithmetic Operators. Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.
Week 2: Console I/O and Operators Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.1) CS 1428 Fall 2014 Jill Seaman 1 2.14 Arithmetic Operators An operator is a symbol that tells the computer to perform specific
More informationC Programs: Simple Statements and Expressions
.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar.. C Programs: Simple Statements and Expressions C Program Structure A C program that consists of only one function has the following
More informationANSI C Programming Simple Programs
ANSI C Programming Simple Programs /* This program computes the distance between two points */ #include #include #include main() { /* Declare and initialize variables */ double
More informationChapter 6 - Notes User-Defined Functions I
Chapter 6 - Notes User-Defined Functions I I. Standard (Predefined) Functions A. A sub-program that performs a special or specific task and is made available by pre-written libraries in header files. B.
More informationJava Methods. Lecture 8 COP 3252 Summer May 23, 2017
Java Methods Lecture 8 COP 3252 Summer 2017 May 23, 2017 Java Methods In Java, the word method refers to the same kind of thing that the word function is used for in other languages. Specifically, a method
More informationEngineering Problem Solving with C++, Etter/Ingber
Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs C++, Second Edition, J. Ingber 1 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input
More informationBIL 104E Introduction to Scientific and Engineering Computing. Lecture 4
BIL 104E Introduction to Scientific and Engineering Computing Lecture 4 Introduction Divide and Conquer Construct a program from smaller pieces or components These smaller pieces are called modules Functions
More informationECET 264 C Programming Language with Applications
ECET 264 C Programming Language with Applications Lecture 10 C Standard Library Functions Paul I. Lin Professor of Electrical & Computer Engineering Technology http://www.etcs.ipfw.edu/~lin Lecture 10
More informationStandard Library Functions Outline
Standard Library Functions Outline 1. Standard Library Functions Outline 2. Functions in Mathematics #1 3. Functions in Mathematics #2 4. Functions in Mathematics #3 5. Function Argument 6. Absolute Value
More informationFunctions and Recursion
Functions and Recursion 1 Outline Introduction Program Components in C++ Math Library Functions Functions Function Definitions Function Prototypes Header Files Random Number Generation Example: A Game
More informationUsing Free Functions
Chapter 3 Using Free Functions 3rd Edition Computing Fundamentals with C++ Rick Mercer Franklin, Beedle & Associates Goals Evaluate some mathematical and trigonometric functions Use arguments in function
More informationIntroduction to Computer Programming in Python Dr. William C. Bulko. Data Types
Introduction to Computer Programming in Python Dr William C Bulko Data Types 2017 What is a data type? A data type is the kind of value represented by a constant or stored by a variable So far, you have
More informationIntroduction to Computer Science Unit 2. Notes
Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and
More information9 Using Equation Networks
9 Using Equation Networks In this chapter Introduction to Equation Networks 244 Equation format 247 Using register address lists 254 Setting up an enable contact 255 Equations displayed within the Network
More informationDownloaded from Chapter 2. Functions
Chapter 2 Functions After studying this lesson, students will be able to: Understand and apply the concept of module programming Write functions Identify and invoke appropriate predefined functions Create
More informationFunction I/O. Function Input and Output. Input through actual parameters. Output through return value. Input/Output through side effects
Function Input and Output Input through actual parameters Output through return value Only one value can be returned Input/Output through side effects printf scanf 2 tj Function Input and Output int main(void){
More informationDr M Kasim A Jalil. Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson)
Lecture 9 Functions Dr M Kasim A Jalil Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson) Objectives In this chapter, you will learn: To understand how to construct programs modularly
More informationCT 229 Fundamentals of Java Syntax
CT 229 Fundamentals of Java Syntax 19/09/2006 CT229 New Lab Assignment Monday 18 th Sept -> New Lab Assignment on CT 229 Website Two Weeks for Completion Due Date is Oct 1 st Assignment Submission is online
More informationChapter 3 - Functions
Chapter 3 - Functions 1 Outline 3.1 Introduction 3.2 Program Components in C++ 3.3 Math Library Functions 3.4 Functions 3.5 Function Definitions 3.6 Function Prototypes 3.7 Header Files 3.8 Random Number
More informationFunctions and an Introduction to Recursion Pearson Education, Inc. All rights reserved.
1 6 Functions and an Introduction to Recursion 2 Form ever follows function. Louis Henri Sullivan E pluribus unum. (One composed of many.) Virgil O! call back yesterday, bid time return. William Shakespeare
More informationFunction I/O. Last Updated 10/30/18
Last Updated 10/30/18 Program Structure Includes Function Declarations void main(void){ foo = fun1(a, b); fun2(2, c); if(fun1(c, d)) { } } Function 1 Definition Function 2 Definition 2 tj Function Input
More informationChapter 2. Outline. Simple C++ Programs
Chapter 2 Simple C++ Programs Outline Objectives 1. Building C++ Solutions with IDEs: Dev-cpp, Xcode 2. C++ Program Structure 3. Constant and Variables 4. C++ Operators 5. Standard Input and Output 6.
More informationAP CS Unit 3: Control Structures Notes
AP CS Unit 3: Control Structures Notes The if and if-else Statements. These statements are called control statements because they control whether a particular block of code is executed or not. Some texts
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 informationJava Classes: Math, Integer A C S L E C T U R E 8
Java Classes: Math, Integer A C S - 1903 L E C T U R E 8 Math class Math class is a utility class You cannot create an instance of Math All references to constants and methods will use the prefix Math.
More information4. Modules and Functions
4. Modules and Functions The Usual Idea of a Function Topics Modules Using import Using functions from math A first look at defining functions sqrt 9 3 A factory that has inputs and builds outputs. Why
More informationLecture 6: While Loops and the Math Class
Lecture 6: While Loops and the Math Class Building Java Programs: A Back to Basic Approach by Stuart Reges and Marty Stepp Copyright (c) Pearson 2013. All rights reserved. while loops 2 Categories of loops
More informationProgramming: Java. Chapter Objectives. Control Structures. Chapter 4: Control Structures I. Program Design Including Data Structures
Chapter 4: Control Structures I Java Programming: Program Design Including Data Structures Chapter Objectives Learn about control structures Examine relational and logical operators Explore how to form
More informationPROGRAMMING WITH MATLAB DR. AHMET AKBULUT
PROGRAMMING WITH MATLAB DR. AHMET AKBULUT OVERVIEW WEEK 1 What is MATLAB? A powerful software tool: Scientific and engineering computations Signal processing Data analysis and visualization Physical system
More informationCT 229 Methods Continued
CT 229 Methods Continued 13/10/2006 CT229 Lab Assignments Due Date for current lab assignment : Oct 20 th In Part 1 of Assignment you can declare a constant 3.14 to use as PI or you can use Math.PI Formula
More informationIntroduction to Computer Science Unit 2. Notes
Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and
More informationProduct Price Formula extension for Magento2. User Guide
Product Price Formula extension for Magento2 User Guide version 1.0 Page 1 Contents 1. Introduction... 3 2. Installation... 3 2.1. System Requirements... 3 2.2. Installation...... 3 2.3. License... 3 3.
More informationProgramming in the Small II: Control
Programming in the Small II: Control 188230 Advanced Computer Programming Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University Agenda Selection
More informationArithmetic. 2.2.l Basic Arithmetic Operations. 2.2 Arithmetic 37
2.2 Arithmetic 37 This is particularly important when programs are written by more than one person. It may be obvious to you that cv stands for can volume and not current velocity, but will it be obvious
More informationC++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 6: User-Defined Functions I
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 6: User-Defined Functions I In this chapter, you will: Objectives Learn about standard (predefined) functions and discover
More informationSummary of basic C++-commands
Summary of basic C++-commands K. Vollmayr-Lee, O. Ippisch April 13, 2010 1 Compiling To compile a C++-program, you can use either g++ or c++. g++ -o executable_filename.out sourcefilename.cc c++ -o executable_filename.out
More informationData Types and Basic Calculation
Data Types and Basic Calculation Intrinsic Data Types Fortran supports five intrinsic data types: 1. INTEGER for exact whole numbers e.g., 1, 100, 534, -18, -654321, etc. 2. REAL for approximate, fractional
More informationIntroduction to Python, Cplex and Gurobi
Introduction to Python, Cplex and Gurobi Introduction Python is a widely used, high level programming language designed by Guido van Rossum and released on 1991. Two stable releases: Python 2.7 Python
More informationCIS133J. Working with Numbers in Java
CIS133J Working with Numbers in Java Contents: Using variables with integral numbers Using variables with floating point numbers How to declare integral variables How to declare floating point variables
More informationOrdinary Differential Equation Solver Language (ODESL) Reference Manual
Ordinary Differential Equation Solver Language (ODESL) Reference Manual Rui Chen 11/03/2010 1. Introduction ODESL is a computer language specifically designed to solve ordinary differential equations (ODE
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 informationLecture 14. Daily Puzzle. Math in C. Rearrange the letters of eleven plus two to make this mathematical statement true. Eleven plus two =?
Lecture 14 Math in C Daily Puzzle Rearrange the letters of eleven plus two to make this mathematical statement true. Eleven plus two =? Daily Puzzle SOLUTION Eleven plus two = twelve plus one Announcements
More informationAll copyrights reserved - KV NAD, Aluva. Dinesh Kumar Ram PGT(CS) KV NAD Aluva
All copyrights reserved - KV NAD, Aluva Dinesh Kumar Ram PGT(CS) KV NAD Aluva Overview Looping Introduction While loops Syntax Examples Points to Observe Infinite Loops Examples using while loops do..
More informationINTRODUCTION TO C++ FUNCTIONS. Dept. of Electronic Engineering, NCHU. Original slides are from
INTRODUCTION TO C++ FUNCTIONS Original slides are from http://sites.google.com/site/progntut/ Dept. of Electronic Engineering, NCHU Outline 2 Functions: Program modules in C Function Definitions Function
More informationNumerical Data. CS 180 Sunil Prabhakar Department of Computer Science Purdue University
Numerical Data CS 180 Sunil Prabhakar Department of Computer Science Purdue University Problem Write a program to compute the area and perimeter of a circle given its radius. Requires that we perform operations
More informationPrasanth Kumar K(Head-Dept of Computers)
B.Sc (Computer Science) Object Oriented Programming with Java and Data Structures Unit-II 1 1. Define operator. Explain the various operators in Java. (Mar 2010) (Oct 2011) Java supports a rich set of
More informationOperators Functions Order of Operations Mixed Mode Arithmetic VOID Data. Syntax and type conventions Using the Script window interface
Introduction Syntax Operators Functions Order of Operations Mixed Mode Arithmetic VOID Data Introduction Map Layer Mathematics Algebraic statements are used to perform the basic mathematical operations
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 informationMatlab Programming Introduction 1 2
Matlab Programming Introduction 1 2 Mili I. Shah August 10, 2009 1 Matlab, An Introduction with Applications, 2 nd ed. by Amos Gilat 2 Matlab Guide, 2 nd ed. by D. J. Higham and N. J. Higham Starting Matlab
More informationOutline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An
CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some
More information3.1. Chapter 3: The cin Object. Expressions and Interactivity
Chapter 3: Expressions and Interactivity 3.1 The cin Object Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 3-1 The cin Object Standard input stream object, normally the keyboard,
More informationIntroduction to C Language
Introduction to C Language Instructor: Professor I. Charles Ume ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Introduction to C Language History of C Language In 1972,
More informationUsing the um-fpu with the Javelin Stamp
Using the um-fpu with the Javelin Stamp Introduction The um-fpu is a 32-bit floating point coprocessor that can be easily interfaced with the Javelin Stamp to provide support for 32-bit IEEE 754 floating
More informationQuick MATLAB Syntax Guide
Quick MATLAB Syntax Guide Some useful things, not everything if-statement Structure: if (a = = = ~=
More informationCS110: PROGRAMMING LANGUAGE I
CS110: PROGRAMMING LANGUAGE I Computer Science Department Lecture 8: Methods Lecture Contents: 2 Introduction Program modules in java Defining Methods Calling Methods Scope of local variables Passing Parameters
More informationOutline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.
CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some
More informationHow to Design Programs Languages
How to Design Programs Languages Version 4.1 August 12, 2008 The languages documented in this manual are provided by DrScheme to be used with the How to Design Programs book. 1 Contents 1 Beginning Student
More information2 Making Decisions. Store the value 3 in memory location y
2.1 Aims 2 Making Decisions By the end of this worksheet, you will be able to: Do arithmetic Start to use FORTRAN intrinsic functions Begin to understand program flow and logic Know how to test for zero
More informationLecture 5: Methods CS2301
Lecture 5: Methods NADA ALZAHRANI CS2301 1 Opening Problem Find the sum of integers from 1 to 10, from 20 to 30, and from 35 to 45, respectively. 2 Solution public static int sum(int i1, int i2) { int
More informationC++ PROGRAMMING SKILLS Part 3 User-Defined Functions
C++ PROGRAMMING SKILLS Part 3 User-Defined Functions Introduction Function Definition Void function Global Vs Local variables Random Number Generator Recursion Function Overloading Sample Code 1 Functions
More informationImportant Java terminology
1 Important Java terminology The information we manage in a Java program is either represented as primitive data or as objects. Primitive data פרימיטיביים) (נתונים include common, fundamental values as
More informationIntroduction to MATLAB
Introduction to MATLAB Dr./ Ahmed Nagib Mechanical Engineering department, Alexandria university, Egypt Sep 2015 Chapter 5 Functions Getting Help for Functions You can use the lookfor command to find functions
More information