COMPUTER PROGRAMMING I Objective 7.03 Apply Built-in Math Class Functions Image taken from:

Slides:



Advertisements
Similar presentations
Return values.
Advertisements

Arithmetic in Pascal (2) Arithmetic Functions Perform arithmetic calculations Gives an argument to the function and it returns the result.
1 Lecture 6 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
1 Chapter 3 Arithmetic Expressions. 2 Chapter 3 Topics l Overview of Java Data Types l Numeric Data Types l Declarations for Numeric Expressions l Simple.
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.
Programming Languages
Variable Declaration  It is possible to declare multiple variables of the same data type on the same line.  Ex. double hours, rate, total;  Variables.
CS0004: Introduction to Programming Variables – Strings.
IMS 3253: Math 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Five Fundamental Math Operations Precedence of Math.
Copyright ©2005  Department of Computer & Information Science Using Number & Math Objects.
COMPUTER PROGRAMMING I Objective 7.03 Apply Built-in Math Class Functions.
MATH AND RANDOM CLASSES.  The need for random numbers occurs frequently when writing software.  The Random class, which is part of the java.util class,
Procedures and Functions Computing Module 1. What is modular programming? Most programs written for companies will have thousands of lines of code. Most.
CSC Programming I Lecture 5 August 30, 2002.
1 CSE1301 Computer Programming Lecture 5: Components of a C Program (Part 1) Linda M c Iver.
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.
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.
3-1 Computing Fundamentals with C++ Object-Oriented Programming and Design, 2nd Edition Rick Mercer Franklin, Beedle & Associates, 1999 ISBN
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.
Numbers © Copyright 2014, Fred McClurg All Rights Reserved.
Chapter 8: Arrays and Functions Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills
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.
CS111 Computer Programming Department of Computer Science Wellesley College Classic Recursion Examples Plus Class Methods and Applications Tuesday, October.
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.
CS4 –lecture 6 Wednesday, Jan 19, 2011 Roxana Gheorghiu.
Computer Science 112 Fundamentals of Programming II.
Controlling Program Flow with Decision Structures.
Conditional Control Structures Chapter 5. Goals and Objectives Understand conditional control structures. Demonstrate the use of decision structures to.
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.
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
Objective 7.03 Apply Built-in Math Class Functions
Math Class Your favorite class!.
Data Types and Conversions, Input from the Keyboard
Chapter 4 Mathematical Functions, Characters, and Strings
Use TryParse to Validate User Input
Chapter 3 Methods.
The Math class The java.lang.Math class contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square.
Numerical Functions & Tricks
Numbers.
Chapter 5 Functional Methods.
Sub Procedures and Functions
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
METHODS, CLASSES, AND OBJECTS A FIRST LOOK
COMPUTER PROGRAMMING SKILLS
Php – Math functions.
Using java libraries CGS3416 spring 2019.
More Basics of Python Common types of data we will work with
Objective 7.03 Apply Built-in Math Class Functions
Chapter 5 Functional Methods.
Presentation transcript:

COMPUTER PROGRAMMING I Objective 7.03 Apply Built-in Math Class Functions Image taken from:

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:

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() FunctionintNum Value after execution intNum = Math.Abs(4)4 sngNum = Math.Abs(-4.123)4.123 intNum = Math.Abs(0)0 Image taken from:

Using Sqrt(num) Sqrt(num) Returns the square root of a number as a double Sqrt() FunctiondblNum 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:

Using Sign(num) The Sign() function works with the following data types:  Decimal, Double, Int16, Int32, Int64, SByte, Single Sign() FunctionintNum Value after execution intNum = Math.Sign(4)1 intNum = Math.Sign(-4) intNum = Math.Sign(0)0 Image taken from:

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() FunctiondblNum Value after execution dblNum = Math.Round( , 2)5.24 decNum = Math.Round( )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  us/library/32s6akha(v=VS.90).aspx us/library/32s6akha(v=VS.90).aspx 