Objective 7.03 Apply Built-in Math Class Functions

Slides:



Advertisements
Similar presentations
Arithmetic in Pascal (2) Arithmetic Functions Perform arithmetic calculations Gives an argument to the function and it returns the result.
Advertisements

Object Oriented Programming A programming concept which views programs as objects with properties and ways to manipulate the object and the properties.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 3: Parameters, Return, and Interactive Programs with Scanner.
TK1913-C Programming1 TK1913-C Programming 1 C Library Functions C provides a collection of library functions for programmers If these library functions.
COMPUTER PROGRAMMING II SUMMER 2011 Visual Basic to C#
Like our natural language. Designed to facilitate the expression and communication ideas between people and computer Like our natural language. Designed.
Using Object-Oriented JavaScript CST 200- JavaScript 4 –
CS0004: Introduction to Programming Variables – Numbers.
Variable Declaration  It is possible to declare multiple variables of the same data type on the same line.  Ex. double hours, rate, total;  Variables.
Copyright ©2005  Department of Computer & Information Science Using Number & Math Objects.
COMPUTER PROGRAMMING I Objective 7.03 Apply Built-in Math Class Functions.
CSC Programming I Lecture 5 August 30, 2002.
COMPUTER PROGRAMMING I SUMMER Apply operators and Boolean expressions.
GCOC – A.P. Computer Science A. College Board Topics – A.P. Computer Science A Program Design - Read and understand a problem's description, purpose,
Java Program Components Java Keywords - Java has special keywords that have meaning in Java. - You have already seen a fair amount of keywords. Examples.
COMPUTER PROGRAMMING I Objective 7.03 Apply Built-in Math Class Functions Image taken from:
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Methods (a.k.a. Functions)
Math With Java The Math Class. First, A Quick Review of Math Operators in Java Primitive Data type in Java that represent numbers: Primitive Data type.
Math Class Part of the Java.lang package. This package is from object so you do not have to import the lang package. Static: Math Class is static.
Numerical Functions & Tricks In today’s lesson we will look at: why we might want to use mathematical techniques some useful functions other mathematical.
Applications Development
COMPUTER PROGRAMMING I SUMMER Apply operators and Boolean expressions.
Lesson 6 Selection Structures. Example program //This will convert a numeric grade into a letter grade import TerminalIO.KeyboardReader; public class.
Introduction As programmers, we don’t want to have to implement functions for every possible task we encounter. The Standard C library contains functions.
The Math Class Methods Utilizing the Important Math Operations of Java!
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
Chapter 8.  Visual Basic includes several built-in mathematical functions ◦ Abs ◦ Sqr ◦ Sgn ◦ IsNumeric ◦ Round ◦ Format ◦ Pmt ◦ PV ◦ FV.
COMPUTER PROGRAMMING I SUMMER Apply operators and Boolean expressions.
Math Class Mrs. C. Furman September 2, Math frequently used methods NameUse floor()rounds down ceil()rounds up pow(x,y)returns x to the power of.
Computer Science 112 Fundamentals of Programming II.
5.02B Decision Making Structure (part 2). Compound Boolean Expressions.
160 as a product of its prime factors is 2 5 x 5 Use this information to show that 160 has 12 factors.
COMPUTER PROGRAMMING I Objective 7.04 Apply Built-in Math Class Functions.
Chapter 4 Mathematical Functions, Characters, and Strings 1.
Use TryParse to Validate User Input
5.03 Apply operators and Boolean expressions
Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2012
5.04 Apply Decision Making Structures
Chapter 4 Mathematical Functions, Characters, and Strings
Math class Random() method Floor method Top-level parseInt function
Objective 7.03 Apply Built-in Math Class Functions
Math Class Your favorite class!.
Data Types and Conversions, Input from the Keyboard
BIL 104E Introduction to Scientific and Engineering Computing
Chapter 4 Mathematical Functions, Characters, and Strings
Functions, Part 2 of 2 Topics Functions That Return a Value
Lesson 18 Math Functions Lesson 19 Format Functions
Use TryParse to Validate User Input
Lesson 4.8 Concept: Comparing positive and negative fractions, decimals and mixed numbers Guidelines: When comparing, all numerical representations must.
Chapter 3 Methods.
Working with Text and Numbers in Java
The Math class The java.lang.Math class contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square.
Using Free Functions Chapter 3 Computing Fundamentals with C++
Numerical Functions & Tricks
Numbers.
Procedures and Functions
Subprograms and Programmer Defined Data Type
Chapter 5 Functional Methods.
Sub Procedures and Functions
Data Types and Variables Part A – Introduction Numeric Data Types
Chapter 5 Methods.
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
METHODS, CLASSES, AND OBJECTS A FIRST LOOK
Building Java Programs
Bell Ringer Replace each ___ with , or = to make a true statement. #1. #2. Order each group of numbers from least to greatest. #3. #4.
COMPUTER PROGRAMMING SKILLS
Php – Math functions.
Using java libraries CGS3416 spring 2019.
More Basics of Python Common types of data we will work with
Chapter 5 Functional Methods.
Presentation transcript:

Objective 7.03 Apply Built-in Math Class Functions Computer Programming I Image taken from: http://www.stsd.org/webpages/cyurconic/news.cfm?subpage=67815

Objects/Classes and Methods in Visual Basic An object is a structure containing data and methods that manipulate the data. Almost everything you do in Visual Basic is associated with objects. If you are new to object-oriented programming, the following terms and concepts will help you get started. Classes and Objects The words "class" and "object" are used so much in object-oriented programming that it is easy to get the terms mixed up. Generally speaking, a class is an abstract representation of something, whereas an object is a usable example of the thing the class represents.

Objects/Classes and Methods in Visual Basic Methods – Functions Methods are operations that can be performed on data. A method may take some input values through its parameters and may return a value of a particular data type. There are two types of methods in VB: Sub Procedures and Functions. For this Unit, we will discuss two built in classes with built in Functions: The Math and String classes.

Math Class Functions The Math class provides programmers with numerous built-in functions. We will only look at a few of these functions. Abs(num) Returns the absolute value of a positive or negative number Sqrt(num) Returns the square root of a number Sign(num) Returns the sign of a number Round (num, places) Returns number nearest to the specified value. Image taken from: http://www.amazingclassroom.com/templates/blue_business/math_1.asp?cag=sample1

Using Abs(num) The Abs() function returns the absolute value of the number and works with the following data types: Decimal, Double, Integer, Single Abs() Function intNum Value after execution intNum = Math.Abs(4) 4 sngNum = Math.Abs(-4.123) 4.123 intNum = Math.Abs(0) Image taken from: http://withlovero.com/2012/05/15/absolute-value-17-2/

Using Sqrt(num) Sqrt(num) Returns the square root of a number as a double Sqrt() Function dblNum Value after execution dblNum = Math.Sqrt(4) 2.0 dblNum = Math.Sqrt(0) 0.0 dblNum = Math.Sqrt(-4) NaN (not a number) (NaN represents a value that is not a number) Image taken from: http://keep3.sjfc.edu/students/anb02630/e-port/vsg/virtual%20strudy%20guide%2021.html

Using Sign(num) The Sign() function works with the following data types: Decimal, Double, Int16, Int32, Int64, SByte, Single Sign() Function intNum Value after execution intNum = Math.Sign(4) 1 intNum = Math.Sign(-4) -1 intNum = Math.Sign(0) Image taken from: https://www.honors.umass.edu/event/last-day-adddrop

Round Function The Round() function works with either a decimal or a double. The variable/value that represents the number of places should be an Integer. Round() Function dblNum Value after execution dblNum = Math.Round(5.23651, 2) 5.24 decNum = Math.Round(5.23651) 5.0 dblNum = Math.Round(5.5) 6.0 decNum = Math.Round(5.225, 2) 5.23 Note that 5 does round up here.

More info? This PowerPoint provided an overview of several methods in the Math class in Visual Studio. For more information on this topic http://msdn.microsoft.com/en-us/library/32s6akha(v=VS.90).aspx http://msdn.microsoft.com/en-us/library/system.math.aspx