Computational Expression

Similar documents
Computational Expression

Computational Expression

Java API: Math, Wrapper Classes, StringBuffer Random Data Quiz2

Computational Expression

We now start exploring some key elements of the Java programming language and ways of performing I/O

Introduction to Computer Science I

Introduction to Computer Science I

Multiple Choice Using Object Methods

Computational Expression

Using Classes and Objects

Introduction to Computer Science I

Lab5. Wooseok Kim

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

Building Java Programs

Data Conversion & Scanner Class

A+ Computer Science -

Using Java Classes Fall 2018 Margaret Reid-Miller

Lab5. Wooseok Kim

Formatting Output & Enumerated Types & Wrapper Classes

A variable is a name for a location in memory A variable must be declared

! definite loop: A loop that executes a known number of times. " The for loops we have seen so far are definite loops. ! We often use language like

Computational Expression

Introduction to Bioinformatics

Using APIs. Chapter 3. Outline Fields Overall Layout. Java By Abstraction Chapter 3. Field Summary static double PI

AP Computer Science Unit 1. Writing Programs Using BlueJ

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

Building Java Programs

A+ Computer Science -

Object Oriented Programming. Java-Lecture 1

Fundamentals of Programming Data Types & Methods

Lesson 02 Data Types and Statements. MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL

Introduction to Java Unit 1. Using BlueJ to Write Programs

Chapter 2: Objects and Primitive Data

Classes and Objects Miscellany: I/O, Statics, Wrappers & Packages. CMSC 202H (Honors Section) John Park

AP Computer Science Unit 1. Writing Programs Using BlueJ

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

CSC Algorithms and Data Structures I. Midterm Examination February 25, Name:

Example packages from Java s standard class library:

CS 200 Using Objects. Jim Williams, PhD

AP Computer Science Unit 1. Programs

The keyword list thus far: The Random class. Generating "Random" Numbers. Topic 16

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

Topic 16. battle -they are strictly limited in number, they require fresh horses, and must only be made at decisive moments." -Alfred North Whitehead

AP Computer Science A

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

CS1083 Week 2: Arrays, ArrayList

ECE 122 Engineering Problem Solving with Java

Objectives of CS 230. Java portability. Why ADTs? 8/18/14

CS 302: Introduction to Programming

CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI

COMP 202. Built in Libraries and objects. CONTENTS: Introduction to objects Introduction to some basic Java libraries string

Lesson 02 Data Types and Statements. MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 25, Name: KEY A

COMP6700/2140 Std. Lib., I/O

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

Programming with Java

Important Java terminology

Chapter 2: Using Data

Lab 5. Name: Checked: Part A. Focus on Strings

Description of the XDA/XDR mesh format used in libmesh

Full file at

Classes and Objects Part 1

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

C/C++ Programming for Engineers: Working with Integer Variables

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming

Computational Expression

The Math Class. Using various math class methods. Formatting the values.

CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II

ECE 122. Engineering Problem Solving with Java

Data and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on:

-Alfred North Whitehead. Copyright Pearson Education, 2010 Based on slides by Marty Stepp and Stuart Reges from

Class Libraries and Packages

AP CS Unit 3: Control Structures Notes

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

2/3/2018 CS313D: ADVANCED PROGRAMMING LANGUAGE. Lecture 3: C# language basics II. Lecture Contents. C# basics. Methods Arrays. Dr. Amal Khalifa, Spr17

Introduction to Computer Science Unit 2. Notes

Peer Instruction 1. Elementary Programming

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

CSC 1351: Quiz 6: Sort and Search

Computational Expression

Reading Input from Text File

Primitive Data Types: Intro

Objects and Classes -- Introduction

Using Classes and Objects

Objects and Classes 1: Encapsulation, Strings and Things CSC 121 Fall 2014 Howard Rosenthal

Experiment No: Group B_4

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java

Welcome to the Using Objects lab!

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

Java Libraries. Lecture 6 CGS 3416 Fall September 21, 2015

Project 1. Java Data types and input/output 1/17/2014. Primitive data types (2) Primitive data types in Java

CSCI 1103: File I/O, Scanner, PrintWriter

Introduction to Computer Science Unit 2. Notes

Using Classes and Objects

Lecture 7. Random number generation More randomized data structures Skip lists: ideas and implementation Skip list time costs

Arrays. CSE 142, Summer 2002 Computer Programming 1.

Programming Language Concepts Scoping. Janyl Jumadinova January 31, 2017

Using Classes and Objects. Chapter

Transcription:

Computational Expression, Math Class, Wrapper Classes Janyl Jumadinova 18 February, 2019 Janyl Jumadinova Computational Expression 18 February, 2019 1 / 8

The Random class is part of the java.util package It provides methods that generate pseudorandom numbers Janyl Jumadinova Computational Expression 18 February, 2019 2 / 8

The Random class is part of the java.util package It provides methods that generate pseudorandom numbers Before you can use its methods, you must create an instance of the Random class Random rand = new Random( ); Janyl Jumadinova Computational Expression 18 February, 2019 2 / 8

float nextfloat( ) float nextdouble( ) - Returns a random number between 0.0 inclusive and 1.0 exclusive. Janyl Jumadinova Computational Expression 18 February, 2019 3 / 8

float nextfloat( ) float nextdouble( ) - Returns a random number between 0.0 inclusive and 1.0 exclusive. Random rand = new Random( ); float f; f = rand.nextfloat( ); Janyl Jumadinova Computational Expression 18 February, 2019 3 / 8

int nextint( ) - Returns a random number that ranges over all possible int values positive and negative. Janyl Jumadinova Computational Expression 18 February, 2019 4 / 8

int nextint( ) - Returns a random number that ranges over all possible int values positive and negative. Random rand = new Random( ); int num; num = rand.nextint( ); Janyl Jumadinova Computational Expression 18 February, 2019 4 / 8

int nextint( ) - Returns a random number that ranges over all possible int values positive and negative. Random rand = new Random( ); int num; num = rand.nextint( ); int nextint( int num ) - Returns a random number between 0 (inclusive) and num (exclusive). Janyl Jumadinova Computational Expression 18 February, 2019 4 / 8

int nextint( ) - Returns a random number that ranges over all possible int values positive and negative. Random rand = new Random( ); int num; num = rand.nextint( ); int nextint( int num ) - Returns a random number between 0 (inclusive) and num (exclusive). Random rand = new Random( ); int num; num = rand.nextint(5 ); Janyl Jumadinova Computational Expression 18 February, 2019 4 / 8

Math Class Math plays a large role in computer programs. Because of this, there is an entire class (Math) that provides easy-to-use interfaces to many common mathematical methods. Unlike most other classes, the Math class is part of the java.lang package, which is imported automatically by the compiler when you compile a program. Therefore, you don t need to do anything special in your program to have access to these methods. Janyl Jumadinova Computational Expression 18 February, 2019 5 / 8

Math Class Math class consists of: static methods, which are methods that don t depend on the contents of an object. static fields, which are values that are usually defined to be public, final and static, meaning that anyone can access them outside the package. Since their values are final, that means that they are constant and can t be changed. Janyl Jumadinova Computational Expression 18 February, 2019 6 / 8

Math Class Examples Janyl Jumadinova Computational Expression 18 February, 2019 7 / 8

Wrapper Classes May want to have an object hold a simple primitive value. Janyl Jumadinova Computational Expression 18 February, 2019 8 / 8

Wrapper Classes May want to have an object hold a simple primitive value. A wrapper class represents a particular primitive type. Janyl Jumadinova Computational Expression 18 February, 2019 8 / 8

Wrapper Classes May want to have an object hold a simple primitive value. A wrapper class represents a particular primitive type. For example, Integer represents a simple integer value. An object created from the Integer class stores a single int value. Janyl Jumadinova Computational Expression 18 February, 2019 8 / 8