What did we talk about last time? Math methods boolean operations char operations

Size: px
Start display at page:

Download "What did we talk about last time? Math methods boolean operations char operations"

Transcription

1 Week 3 - Wednesday

2 What did we talk about last time? Math methods boolean operations char operations

3

4

5 For Project 1, the easiest way to print out data with 2 decimal places is put "%.2f" in the formatting string for System.out.format() double x = ; System.out.format("%.2f", x); //prints 5.75 If you want, you can include other things in the formatting string System.out.format("Total = $%.2f", ); //prints Total = $15.78

6

7 A method is a piece of Java code that has been packaged up so that you can use it over and over Usually, a method will take some input and give some output System.out.println() is an example of a method Using a method (calling a method) always requires parentheses

8 The sin() method allows you to find the sine of an angle (in radians) This method is inside the Math class The answer that it gives back is of type double To use it, you might type the following: double value = Math.sin( 2.4 );

9 Unless the method is inside your class, you must supply a class name and a dot If your method takes input, you put it inside the parentheses, if not, you leave them empty result = class.method( input ); You can store the result of the method, as long as the variable matches the type that the method gives back Next, you must give the method name that you are calling

10 Return type Name Job double sin( double theta ) Find the sine of angle theta double cos( double theta ) Find the cosine of angle theta double tan( double theta ) Find the tangent of angle theta double exp( double a ) Raise e to the power of a (e a ) double log( double a ) Find the natural log of a double pow( double a, double b ) Raise a to the power of b (a b ) long round( double a ) Round a to the nearest integer double random() Create a random number in [0, 1) double sqrt( double a ) Find the square root of a double todegrees( double radians ) Convert radians to degrees double toradians( double degrees ) Convert degrees to radians

11 Write a program that takes a base b and an exponent x Print the result of raising b x

12

13 The only operator that we will use directly with String values is the + (concatenation) operator This operator creates a new String that is the concatenation of the two source Strings As with numerical types, the + operator does not change the two Strings being concatenated String word; word = "tick" + "tock"; // word is "ticktock"

14 Concatenation is a great tool for merging lots of different types into a String String word; word = 99 + " problems"; // word is // "99 problems" Confusion can arise: String word; word = "love potion #" ; // word is "love potion #45" word = "love potion #" + (4 + 5); // word is "love potion #9"

15 Objects have data inside of them but also have the ability to do things with methods Among other things, a String can: Compare itself with other Strings Find its length Say which character is located at position i Generate a substring

16 To see if two Strings are identical, use the equals() method: String word1 = "lettuce"; String word2 = "let us"; boolean same = word1.equals ( word2 ); // false If they are the same (including case), the method will return true If they are not, the method will return false

17 To see which String goes first in the dictionary, use the compareto() method: String word1 = "hard work"; String word2 = "success"; int value = word1.compareto( word2 ); // < 0 If word1 comes first, value will be a negative number If word2 comes first, value will be a positive number If they are the same, value will be 0

18 To find the length of a String, use the length() method: String word = "a mile long"; int length = word.length(); // length = 11 It is possible to have a String of length 0: String nothing = ""; int length = nothing.length(); // length = 0

19 To find the char at position i in a String, use the charat() method: String word = "walnut"; char c = word.charat(3); // c = 'n' Woe betide the man (or woman) who asks for a character out of range: String word = "short"; char c = word.charat(10); // ouch!

20 To get a substring of a String, use the substring() method: String word1 = "disco fever"; String word2 = word1.substring(3,7); //word2 = "co f" The first int tells which char to start on, the second int says which char to stop before

21 Write a program that reads a first and a last name Then, output only the person's initials

22

23 There are certain things that are difficult to do with the operations we've shown you For example, how do you turn a String representation of a number like "847" into the actual int 847? Wrapper classes!

24 Each primitive data type in Java has a wrapper class We will focus on 3: Integer Double Character

25 The main uses of the Integer class are converting ints to and from Strings To convert a String to an int, use the parseint() method String number = "345"; int value = Integer.parseInt(number); To convert an int to a String, use the tostring() method (or just concatenate) int value = 543; String number = Integer.toString(value);

26 The Double class is much like the Integer class To convert a String to a double, use the parsedouble() method String number = " "; double value = Double.parseDouble(number); To convert a double to a String, use the tostring() method (or just concatenate) double value = 6.02e23; String number = Double.toString(value);

27 The Character class is mostly useful for getting information about a particular char For example, you can find out whether a char is a digit, is a letter, is uppercase, or is lowercase by calling the isdigit(), isletter(), isuppercase(), or islowercase() methods, respectively char c = '8'; boolean value = Character.isDigit(c); //true

28

29

30 Introduction to if-statements Lab 3

31 Keep reading Chapter 3 of the textbook Keep working on Project 1 Due next Friday

What did we talk about last time? Examples switch statements

What 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 information

1001ICT Introduction To Programming Lecture Notes

1001ICT 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 information

The Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II Instructor: Dr. Bowen Hui. Tuesday, April 19, 2016

The Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II Instructor: Dr. Bowen Hui. Tuesday, April 19, 2016 First Name (Print): Last Name (Print): Student Number: The Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II 2016 Instructor: Dr. Bowen Hui Tuesday, April 19, 2016 Time: 6:00pm

More information

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All This chapter discusses class String, from the java.lang package. These classes provide the foundation for string and character manipulation

More information

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All Advanced Java This chapter discusses class String, class StringBuilder and class Character from the java.lang package. These classes provide

More information

www.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 information

Unit O Student Success Sheet (SSS) Right Triangle Trigonometry (sections 4.3, 4.8)

Unit O Student Success Sheet (SSS) Right Triangle Trigonometry (sections 4.3, 4.8) Unit O Student Success Sheet (SSS) Right Triangle Trigonometry (sections 4.3, 4.8) Standards: Geom 19.0, Geom 20.0, Trig 7.0, Trig 8.0, Trig 12.0 Segerstrom High School -- Math Analysis Honors Name: Period:

More information

CISC-124. This week we continued to look at some aspects of Java and how they relate to building reliable software.

CISC-124. This week we continued to look at some aspects of Java and how they relate to building reliable software. CISC-124 20180129 20180130 20180201 This week we continued to look at some aspects of Java and how they relate to building reliable software. Multi-Dimensional Arrays Like most languages, Java permits

More information

Introduction to Programming

Introduction 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 information

Math 144 Activity #4 Connecting the unit circle to the graphs of the trig functions

Math 144 Activity #4 Connecting the unit circle to the graphs of the trig functions 144 p 1 Math 144 Activity #4 Connecting the unit circle to the graphs of the trig functions Graphing the sine function We are going to begin this activity with graphing the sine function ( y = sin x).

More information

ASSIGNMENT 3 Methods, Arrays, and the Java Standard Class Library

ASSIGNMENT 3 Methods, Arrays, and the Java Standard Class Library ASSIGNMENT 3 Methods, Arrays, and the Java Standard Class Library COMP-202B, Winter 2010, All Sections Due: Wednesday, March 3, 2010 (23:55) You MUST do this assignment individually and, unless otherwise

More information

Using Free Functions

Using 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 information

CT 229 Java Syntax Continued

CT 229 Java Syntax Continued CT 229 Java Syntax Continued 06/10/2006 CT229 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

More information

COMP Primitive and Class Types. Yi Hong May 14, 2015

COMP Primitive and Class Types. Yi Hong May 14, 2015 COMP 110-001 Primitive and Class Types Yi Hong May 14, 2015 Review What are the two major parts of an object? What is the relationship between class and object? Design a simple class for Student How to

More information

Using the um-fpu with the Javelin Stamp

Using 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 information

StudyHub+ 1. StudyHub: AP Java. Semester One Final Review

StudyHub+ 1. StudyHub: AP Java. Semester One Final Review StudyHub+ 1 StudyHub: AP Java Semester One Final Review StudyHub+ 2 Terminology: Primitive Data Type: Most basic data types in the Java language. The eight primitive data types are: Char: A single character

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG 1 Notice Assignments Reading Assignment: Chapter 3: Introduction to Parameters and Objects The Class 10 Exercise

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

Review for Test 1 (Chapter 1-5)

Review for Test 1 (Chapter 1-5) Review for Test 1 (Chapter 1-5) 1. Introduction to Computers, Programs, and Java a) What is a computer? b) What is a computer program? c) A bit is a binary digit 0 or 1. A byte is a sequence of 8 bits.

More information

Macro Programming Reference Guide. Copyright 2005 Scott Martinez

Macro Programming Reference Guide. Copyright 2005 Scott Martinez Macro Programming Reference Guide Copyright 2005 Scott Martinez Section 1. Section 2. Section 3. Section 4. Section 5. Section 6. Section 7. What is macro programming What are Variables What are Expressions

More information

CST242 Strings and Characters Page 1

CST242 Strings and Characters Page 1 CST242 Strings and Characters Page 1 1 2 3 4 5 6 Strings, Characters and Regular Expressions CST242 char and String Variables A char is a Java data type (a primitive numeric) that uses two bytes (16 bits)

More information

CS 1301 Ch 8, Part A

CS 1301 Ch 8, Part A CS 1301 Ch 8, Part A Sections Pages Review Questions Programming Exercises 8.1 8.8 264 291 1 30 2,4,6,8,10,12,14,16,18,24,28 This section of notes discusses the String class. The String Class 1. A String

More information

Mathematical Functions, Characters, and Strings. CSE 114, Computer Science 1 Stony Brook University

Mathematical Functions, Characters, and Strings. CSE 114, Computer Science 1 Stony Brook University Mathematical Functions, Characters, and Strings CSE 114, Computer Science 1 Stony Brook University http://www.cs.stonybrook.edu/~cse114 1 Static methods Remember the main method header? public static void

More information

double float char In a method: final typename variablename = expression ;

double float char In a method: final typename variablename = expression ; Chapter 4 Fundamental Data Types The Plan For Today Return Chapter 3 Assignment/Exam Corrections Chapter 4 4.4: Arithmetic Operations and Mathematical Functions 4.5: Calling Static Methods 4.6: Strings

More information

Bil 104 Intiroduction To Scientific And Engineering Computing. Lecture 5. Playing with Data Modifiers and Math Functions Getting Controls

Bil 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 information

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 1, Name: KEY A

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 1, Name: KEY A CSC 1051 Algorithms and Data Structures I Midterm Examination March 1, 2018 Name: KEY A Question Value Score 1 20 2 20 3 20 4 20 5 20 TOTAL 100 Please answer questions in the spaces provided. If you make

More information

Datatypes, Variables, and Operations

Datatypes, 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 information

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University

Lesson #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 information

Methods CSC 121 Fall 2016 Howard Rosenthal

Methods 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 information

OOP-Lecture Java Loop Controls: 1 Lecturer: Hawraa Sh. You can use one of the following three loops: while Loop do...while Loop for Loop

OOP-Lecture Java Loop Controls: 1 Lecturer: Hawraa Sh. You can use one of the following three loops: while Loop do...while Loop for Loop Java Loop Controls: You can use one of the following three loops: while Loop do...while Loop for Loop 1- The while Loop: A while loop is a control structure that allows you to repeat a task a certain number

More information

Using Game Maker 8: GML Scripting

Using Game Maker 8: GML Scripting Using Game Maker 8: GML Scripting Mike Bailey mjb@cs.oregonstate.edu http://cs.oregonstate.edu/~mjb/gamemaker Scripting using the Game Maker Language (GML) There are two neat things about using GML: 1.

More information

Basic types and definitions. Chapter 3 of Thompson

Basic types and definitions. Chapter 3 of Thompson Basic types and definitions Chapter 3 of Thompson Booleans [named after logician George Boole] Boolean values True and False are the result of tests are two numbers equal is one smaller than the other

More information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Lecture 8 More Conditional Statements Outline Problem: How do I make choices in my Java program? Understanding conditional statements Remember: Boolean logic

More information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Lecture 8 More Conditional Statements Outline Problem: How do I make choices in my Java program? Understanding conditional statements Remember: Boolean logic

More information

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Mathematical Functions Java provides many useful methods in the Math class for performing common mathematical

More information

Full file at

Full 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 information

DATA TYPES AND EXPRESSIONS

DATA TYPES AND EXPRESSIONS DATA TYPES AND EXPRESSIONS Outline Variables Naming Conventions Data Types Primitive Data Types Review: int, double New: boolean, char The String Class Type Conversion Expressions Assignment Mathematical

More information

(Type your answer in radians. Round to the nearest hundredth as needed.)

(Type your answer in radians. Round to the nearest hundredth as needed.) 1. Find the exact value of the following expression within the interval (Simplify your answer. Type an exact answer, using as needed. Use integers or fractions for any numbers in the expression. Type N

More information

Methods CSC 121 Fall 2014 Howard Rosenthal

Methods 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 information

MaSH Environment nxt. Contents

MaSH Environment nxt. Contents MaSH Environment nxt Andrew Rock School of Information and Communication Technology Griffith University Nathan, Queensland, 4111, Australia a.rock@griffith.edu.au January 2, 2016 Contents 1 Purpose 3 2

More information

Trigonometric Functions of Any Angle

Trigonometric Functions of Any Angle Trigonometric Functions of Any Angle MATH 160, Precalculus J. Robert Buchanan Department of Mathematics Fall 2011 Objectives In this lesson we will learn to: evaluate trigonometric functions of any angle,

More information

Methods CSC 121 Spring 2017 Howard Rosenthal

Methods 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 information

Java Classes: Math, Integer A C S L E C T U R E 8

Java 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 information

Downloaded from Chapter 2. Functions

Downloaded 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 information

Chapter 4 Fundamental Data Types. Big Java by Cay Horstmann Copyright 2009 by John Wiley & Sons. All rights reserved.

Chapter 4 Fundamental Data Types. Big Java by Cay Horstmann Copyright 2009 by John Wiley & Sons. All rights reserved. Chapter 4 Fundamental Data Types Chapter Goals To understand integer and floating-point numbers To recognize the limitations of the numeric types To become aware of causes for overflow and roundoff errors

More information

2/9/2012. Chapter Four: Fundamental Data Types. Chapter Goals

2/9/2012. Chapter Four: Fundamental Data Types. Chapter Goals Chapter Four: Fundamental Data Types Chapter Goals To understand integer and floating-point numbers To recognize the limitations of the numeric types To become aware of causes for overflow and roundoff

More information

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 4

BIL 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 information

Eng. Mohammed Abdualal

Eng. Mohammed Abdualal Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2124) Lab 2 String & Character Eng. Mohammed Abdualal String Class In this lab, you have

More information

CHAPTER 4 MATHEMATICAL FUNCTIONS, CHARACTERS, STRINGS

CHAPTER 4 MATHEMATICAL FUNCTIONS, CHARACTERS, STRINGS CHAPTER 4 MATHEMATICAL FUNCTIONS, CHARACTERS, STRINGS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH INTRODUCTION TO JAVA PROGRAMMING, LIANG (PEARSON 2014) MATHEMATICAL FUNCTIONS Java

More information

C++, How to Program. Spring 2016 CISC1600 Yanjun Li 1

C++, 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 information

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 11, Name: KEY

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 11, Name: KEY CSC 1051 Algorithms and Data Structures I Midterm Examination October 11, 2018 Name: KEY Question Value Score 1 20 2 20 3 20 4 20 5 20 TOTAL 100 Please answer questions in the spaces provided. If you make

More information

Introduction to Computer Programming

Introduction to Computer Programming Introduction to Computer Programming Classy Programming Techniques I: Introducing Objects What is Object-Oriented Programming? Object-oriented programming (or OOP) attempts to allow the programmer to use

More information

Mathematical Functions, Characters, and Strings. CSE 114, Computer Science 1 Stony Brook University

Mathematical Functions, Characters, and Strings. CSE 114, Computer Science 1 Stony Brook University Mathematical Functions, Characters, and Strings CSE 114, Computer Science 1 Stony Brook University http://www.cs.stonybrook.edu/~cse114 1 Static methods Remember the main method header? public static void

More information

Secondary Math 3- Honors. 7-4 Inverse Trigonometric Functions

Secondary Math 3- Honors. 7-4 Inverse Trigonometric Functions Secondary Math 3- Honors 7-4 Inverse Trigonometric Functions Warm Up Fill in the Unit What You Will Learn How to restrict the domain of trigonometric functions so that the inverse can be constructed. How

More information

Math 144 Activity #3 Coterminal Angles and Reference Angles

Math 144 Activity #3 Coterminal Angles and Reference Angles 144 p 1 Math 144 Activity #3 Coterminal Angles and Reference Angles For this activity we will be referring to the unit circle. Using the unit circle below, explain how you can find the sine of any given

More information

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 2, Name:

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 2, Name: CSC 1051 Algorithms and Data Structures I Midterm Examination March 2, 2017 Name: Question Value Score 1 10 2 10 3 20 4 20 5 20 6 20 TOTAL 100 Please answer questions in the spaces provided. If you make

More information

Lecture 9: Arrays. Building Java Programs: A Back to Basics Approach by Stuart Reges and Marty Stepp. Copyright (c) Pearson All rights reserved.

Lecture 9: Arrays. Building Java Programs: A Back to Basics Approach by Stuart Reges and Marty Stepp. Copyright (c) Pearson All rights reserved. Lecture 9: Arrays Building Java Programs: A Back to Basics Approach by Stuart Reges and Marty Stepp Copyright (c) Pearson 2013. All rights reserved. Can we solve this problem? Consider the following program

More information

Get to Know Your Calculator!

Get to Know Your Calculator! Math BD Calculator Lab Name: Date: Get to Know Your Calculator! You are allowed to use a non-graphing, scientific calculator for this course. A scientific calculator is different from an ordinary hand-held

More information

Math 144 Activity #2 Right Triangle Trig and the Unit Circle

Math 144 Activity #2 Right Triangle Trig and the Unit Circle 1 p 1 Right Triangle Trigonometry Math 1 Activity #2 Right Triangle Trig and the Unit Circle We use right triangles to study trigonometry. In right triangles, we have found many relationships between the

More information

How to Design Programs Languages

How 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 information

Ex: If you use a program to record sales, you will want to remember data:

Ex: 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 information

Name: Checked: Access the Java API at the link above. Why is it abbreviated to Java SE (what does the SE stand for)?

Name: Checked: Access the Java API at the link above. Why is it abbreviated to Java SE (what does the SE stand for)? Lab 5 Name: Checked: Objectives: Learn about the Java API Practice using Math, Random, String, and other classes from the Java API Practice writing code to do basic String processing Preparation: Complete

More information

Topics. Chapter 5. Equality Operators

Topics. Chapter 5. Equality Operators Topics Chapter 5 Flow of Control Part 1: Selection Forming Conditions if/ Statements Comparing Floating-Point Numbers Comparing Objects The equals Method String Comparison Methods The Conditional Operator

More information

Methods (Deitel chapter 6)

Methods (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 information

CS-201 Introduction to Programming with Java

CS-201 Introduction to Programming with Java CS-201 Introduction to Programming with Java California State University, Los Angeles Computer Science Department Lecture V: Mathematical Functions, Characters, and Strings Introduction How would you estimate

More information

MaSH Environment graphics

MaSH Environment graphics MaSH Environment graphics Andrew Rock School of Information and Communication Technology Griffith University Nathan, Queensland, 4111, Australia a.rock@griffith.edu.au June 16, 2014 Contents 1 Purpose

More information

Haskell Programs. Haskell Fundamentals. What are Types? Some Very Basic Types. Types are very important in Haskell:

Haskell Programs. Haskell Fundamentals. What are Types? Some Very Basic Types. Types are very important in Haskell: Haskell Programs We re covering material from Chapters 1-2 (and maybe 3) of the textbook. Haskell Fundamentals Prof. Susan Older A Haskell program is a series of comments and definitions. Each comment

More information

Methods (Deitel chapter 6)

Methods (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 information

Introduction to Programming

Introduction 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 information

MATLAB Constants, Variables & Expression. 9/12/2015 By: Nafees Ahmed

MATLAB Constants, Variables & Expression. 9/12/2015 By: Nafees Ahmed MATLAB Constants, Variables & Expression Introduction MATLAB can be used as a powerful programming language. It do have IF, WHILE, FOR lops similar to other programming languages. It has its own vocabulary

More information

Chapter 4 Mathematical Functions, Characters, and Strings

Chapter 4 Mathematical Functions, Characters, and Strings Chapter 4 Mathematical Functions, Characters, and Strings Liang, Introduction to Java Programming, Tenth Edition, Global Edition. Pearson Education Limited 2015 1 Motivations Suppose you need to estimate

More information

Numerical Data. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

Numerical 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 information

Week 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 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 information

Chapter 3 - Functions

Chapter 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 information

Single row numeric functions

Single row numeric functions Single row numeric functions Oracle provides a lot of standard numeric functions for single rows. Here is a list of all the single row numeric functions (in version 10.2). Function Description ABS(n) ABS

More information

AP Computer Science. Strings. Credit: Slides are modified with permission from Barry Wittman at Elizabethtown College

AP Computer Science. Strings. Credit: Slides are modified with permission from Barry Wittman at Elizabethtown College Strings AP Computer Science Credit: Slides are modified with permission from Barry Wittman at Elizabethtown College This work is licensed under an Attribution-NonCommercial-ShareAlike 3.0 Unported License

More information

Lecture 2 FORTRAN Basics. Lubna Ahmed

Lecture 2 FORTRAN Basics. Lubna Ahmed Lecture 2 FORTRAN Basics Lubna Ahmed 1 Fortran basics Data types Constants Variables Identifiers Arithmetic expression Intrinsic functions Input-output 2 Program layout PROGRAM program name IMPLICIT NONE

More information

HUDSONVILLE HIGH SCHOOL COURSE FRAMEWORK

HUDSONVILLE 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 information

More on variables and methods

More on variables and methods More on variables and methods Robots Learning to Program with Java Byron Weber Becker chapter 7 Announcements (Oct 12) Reading for Monday Ch 7.4-7.5 Program#5 out Character Data String is a java class

More information

int: integers, no fractional part double: floating-point numbers (double precision) 1, -4, 0 0.5, , 4.3E24, 1E-14

int: integers, no fractional part double: floating-point numbers (double precision) 1, -4, 0 0.5, , 4.3E24, 1E-14 int: integers, no fractional part 1, -4, 0 double: floating-point numbers (double precision) 0.5, -3.11111, 4.3E24, 1E-14 A numeric computation overflows if the result falls outside the range for the number

More information

Such JavaScript Very Wow

Such JavaScript Very Wow Such JavaScript Very Wow Lecture 9 CGS 3066 Fall 2016 October 20, 2016 JavaScript Numbers JavaScript numbers can be written with, or without decimals. Extra large or extra small numbers can be written

More information

Customizing Built In Formulas

Customizing Built In Formulas Applies to: Software Component: SAP_BW. For more information, visit the EDW homepage. Summary This document demonstrates the performance of field routine as compared to formulas used in an update rule/

More information

Methods: A Deeper Look

Methods: 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 information

1.1 Your First Program! Naive ideal. Natural language instructions.

1.1 Your First Program! Naive ideal. Natural language instructions. Why Programming? Why programming? Need to tell computer what you want it to do. 1.1 Your First Program Naive ideal. Natural language instructions. Please simulate the motion of these heavenly bodies, subject

More information

10 Using the PCFL Editor In this chapter

10 Using the PCFL Editor In this chapter 10 Using the PCFL Editor In this chapter Introduction to the PCFL editor 260 Editing PCFL registers 261 Customizing the PCFL configuration file 272 ProWORX NxT User s Guide Introduction to the PCFL editor

More information

printf( Please enter another number: ); scanf( %d, &num2);

printf( 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 information

The Absolute Value Symbol

The Absolute Value Symbol Section 1 3: Absolute Value and Powers The Absolute Value Symbol The symbol for absolute value is a pair of vertical lines. These absolute value brackets act like the parenthesis that we use in order of

More information

: Find the values of the six trigonometric functions for θ. Special Right Triangles:

: Find the values of the six trigonometric functions for θ. Special Right Triangles: ALGEBRA 2 CHAPTER 13 NOTES Section 13-1 Right Triangle Trig Understand and use trigonometric relationships of acute angles in triangles. 12.F.TF.3 CC.9- Determine side lengths of right triangles by using

More information

C Functions. 5.2 Program Modules in C

C 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 information

Arduino Part 3. Introductory Medical Device Prototyping

Arduino Part 3. Introductory Medical Device Prototyping Introductory Medical Device Prototyping Arduino Part 3, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota More Arduino Functions More functions: Math functions Trigonometry

More information

Built-in Types of Data

Built-in Types of Data Built-in Types of Data Types A data type is set of values and a set of operations defined on those values Python supports several built-in data types: int (for integers), float (for floating-point numbers),

More information

IDM 232. Scripting for Interactive Digital Media II. IDM 232: Scripting for IDM II 1

IDM 232. Scripting for Interactive Digital Media II. IDM 232: Scripting for IDM II 1 IDM 232 Scripting for Interactive Digital Media II IDM 232: Scripting for IDM II 1 PHP HTML-embedded scripting language IDM 232: Scripting for IDM II 2 Before we dive into code, it's important to understand

More information

JUN / 04 VERSION 7.0

JUN / 04 VERSION 7.0 JUN / 04 VERSION 7.0 PVI EWEXEME www.smar.com Specifications and information are subject to change without notice. Up-to-date address information is available on our website. web: www.smar.com/contactus.asp

More information

C++ PROGRAMMING SKILLS Part 3 User-Defined Functions

C++ 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 information

SM 2. Date: Section: Objective: The Pythagorean Theorem: In a triangle, or

SM 2. Date: Section: Objective: The Pythagorean Theorem: In a triangle, or SM 2 Date: Section: Objective: The Pythagorean Theorem: In a triangle, or. It doesn t matter which leg is a and which leg is b. The hypotenuse is the side across from the right angle. To find the length

More information

AP Computer Science A

AP Computer Science A AP Computer Science A 1st Quarter Notes Table of Contents - section links Click on the date or topic below to jump to that section Date : 9/8/2017 Aim : Java Basics Objects and Classes Data types: Primitive

More information

boolean, char, class, const, double, else, final, float, for, if, import, int, long, new, public, return, static, throws, void, while

boolean, char, class, const, double, else, final, float, for, if, import, int, long, new, public, return, static, throws, void, while CSCI 150 Fall 2007 Java Syntax The following notes are meant to be a quick cheat sheet for Java. It is not meant to be a means on its own to learn Java or this course. For that you should look at your

More information

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8 Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(

More information

Math General Angles, Radian Measure, measures of arcs and sectors

Math General Angles, Radian Measure, measures of arcs and sectors Math-3 6-3 General Angles, Radian Measure, measures of arcs and sectors tan 5 9 5 h cos? 9 ϴ Tangent ratio gives sides of a right triangle. h h h 5 9 5 81 106 cos cos 9 106 9 106 106 cos 3 10 opp 10 sin?

More information

Chapter 2. Outline. Simple C++ Programs

Chapter 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 information