Checking If User Input Is Numeric.  Quiz  Detecting numeric input  Finish Prior Lecture  Y'all work on one of the problems listed 2.

Slides:



Advertisements
Similar presentations
CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
Advertisements

1 COMM 1213 H1 COMP 4923 X1 JavaScript 1 (Readings: Ch. 10, 11 Knuckles)
Opener:  When you’re taking notes, if you have to write the same big word or words over and over again….do you write it out every time? How do you make.
ECS 15 if and random. Topic  Testing user input using if statements  Truth and falsehood in Python  Getting random numbers.
The Binary Numbering Systems
Lesson 4: Formatting Input Data for Arithmetic
8.1 Work Solving Work Problems. 8.1 Solving Work Problems The term “Work” implies that something is getting done. This something can be mowing a lawn,
ECS15 for and sequence. Comments  Another way to repeat.
8 November Forms and JavaScript. Types of Inputs Radio Buttons (select one of a list) Checkbox (select as many as wanted) Text inputs (user types text)
Lecture 2: Topics Bits and Bytes Primitive Types Casting Strings Boolean expressions.
EXAMPLE 1 Multiplying Decimals by Whole Numbers Find the product
Presents. What are integers? positive numbersnegative numbers Integers is the family name for positive and negative whole numbers.
Working with Numbers parseInt() and parseFloat() Math.round() Other Math object functions isNaN() toFixed()
Computer Science 121 Scientific Computing Winter 2014 Chapter 3 Simple Types: Numbers, Text, Booleans.
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
Add, Subtract, Multiply, and Divide Decimals
General Programming Introduction to Computing Science and Programming I.
Copyright ©2005  Department of Computer & Information Science Using Number & Math Objects.
Multiplying Rational Numbers
How do we use the laws of exponents?. The zero power Anything to the power of zero is one.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Rational numbers. Whole numbers Whole numbers Rational numbers Whole numbers Natural numbers Integers / ¾ 18% A rational number.
Algebra and Trigonometry III by: Mr Pol Ogrimen Jr.
CSE1222: Lecture 2The Ohio State University1. mathExample2.cpp // math example #include using namespace std; int main() { cout
Equation Jeopardy Add Mixed Multiply/ Divide Fractions Q $100 Q $200 Q $300 Q $400 Q $500 Q $100 Q $200 Q $300 Q $400 Q $500 Final Jeopardy Subtract.
Variables Damian Gordon. Variables We know what a variable is from maths. We’ve all seen this sort of thing in algebra: 2x – 10 = 0 2x = 10 X = 5.
Bell Work!!! a ÷ (b) 2. c × d 3. d ÷ d 4. c × b
Conditional Statements.  Checking if input is a number  Radio buttons  Check boxes 2.
CSE 341 Lecture 29 a JavaScript, the bad parts slides created by Marty Stepp see also: JavaScript: The Good Parts, by.
Variables and Data Types Data (information we're going to store) – Numbers – Text – Dates What types of data can JavaScript process? How do we store it?
IT253: Computer Organization
Dividing Decimals TeacherTwins©2014. Warm Up
Conditional Statements.  Quiz  Hand in your jQuery exercises from last lecture  They don't have to be 100% perfect to get full credit  They do have.
Decision Structures, String Comparison, Nested Structures
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
ITEC 109 Lecture 7 Operations. Review Variables / Methods Functions Assignments –Purpose? –What provides the data? –What stores the data? –What type of.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Variables.
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
3-1 © 2011 Pearson Prentice Hall. All rights reserved Chapter 8 Rational Exponents, Radicals, and Complex Numbers Active Learning Questions.
Chapter One Lesson Three DATA TYPES ©
A: A: double “4” A: “34” 4.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
21. THE STANDARD LIBRARY. General Rules The C standard library is divided into 15 parts (24 in C99), with each part described by a header. The names of.
What are Operators? Some useful operators to get you started.
5-3(D) Real Numbers.
Logical Operators.  Quiz  Let's look at the schedule  Logical Operators 2.
CONVERTING TO RATIONAL NUMBERS. Whole numbers are 0, 1, 2, 3, 4, … Integers include all the whole numbers and also their negative versions: …, -3, -2,
4-2 Integer Exponents Warm Up Evaluate , , ,000,000.
Math-2 Lesson 5-2 Properties of Exponents part 2.
Integers Integers are positive whole numbers, their opposites (negatives), and zero.
Input, Output and Variables GCSE Computer Science – Python.
Data Types Mr Tottman Link. Data Types Programs need to use data for calculations and for output to various devices The best programs will always use.
Start the Quiz Show the answer Check the answer Time’s up! Timer
Logical Operators.  Quizzes!  Let's look at the schedule  Logical Operators 2.
CST 1101 Problem Solving Using Computers
Number Theory The Integers; Order of Operations Rational Numbers
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Data Structures Mohammed Thajeel To the second year students
Review Operation Bingo
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
The Internet 11/15/11 Handling Data in JavaScript
Variables Kevin Harville.
C# Revision Cards Data types
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Data Types and Maths Programming Guides.
Boolean in C++ CSCE 121.
Section 6 Primitive Data Types
Presentation transcript:

Checking If User Input Is Numeric

 Quiz  Detecting numeric input  Finish Prior Lecture  Y'all work on one of the problems listed 2

3 Checking if a value is a number

 Examples of data types:  Integer - whole numbers only, but positive, negative, and zero are allowed  Floating-point / real - any number (whole or with a decimal point), positive, negative, zero  Strings – text ("a string of individual characters")  Boolean – true or false  JS will try to convert from one to another in order to help you out.  FILE: loose_typing.html  Note: multiplying by two is great  Adding 4 isn't great  Sometimes we need to tell it what to do 4

 The isNaN() function will tell us if it's NOT a number  NaN = Not A Number  parseFloat() will then convert it to a real, floating-point number with decimals  Use parseInt() if you want to drop anything after the decimal point  Then it's safe to do math on it  FILE: checking_for_numbers.html  Step 1: Check if it's actually a number using isNaN (error & exit if it isn't)  Step 2: Convert it to a number using parseFloat/parseInt  Step 3: Do the math 5

 Do exercise #1 for this topic  Once you've got that done, pick problems from exercise #2 to do 6