Formatting Output Slides by Dr. Heuring

Slides:



Advertisements
Similar presentations
Formatting Output For a pleasant interaction with the user.
Advertisements

Scientific Notation.
SCIENTIFIC NOTATION Scientific Notation should be used whenever a situation calls for the use of very large or very small numbers, such as distances in.
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
Scientific Notation. Essential Question  How do I use scientific notation to represent numbers?
 To add numbers in scientific notation: 1) Add the constants 2) Keep the exponent the same  Example: (2.1 x 10 5 ) + (3.2 x 10 5 ) = ( ) x 10.
Scientific Notation Section 8.5.
1. Scientific Notation Every positive number X can be written as:
Multiplying and Dividing by Powers of 10; Scientific Notation
Floating Point in Binary 1.Place Value Chart:
SCIENTIFIC NOTATION Expressing a quantity as: a number between 1 and 10 multiplied by 10 to the appropriate power.
Exponents And how they make life easier! Exponents Exponents are used to write numbers in scientific notation. Exponents are powers of ten. 10 x 10 =
Move the decimal point to get a factor greater than 1 but less than 10.. The mean distance from Mars to the sun is about 141,750,000 mi. Write this number.
Scientific Notation (large numbers) Textbook page 114.
digit x 1 digit 3 DIGIT BY 2 DIGIT Multiplying Decimals 4 digit by 3 digit
To make a fraction with a negative exponent: 1) Place a one over the number with the exponent. 2) Multiply the exponent out underneath. Scientific to.
Aim: How do we use scientific Notation? It's Not Science Fiction...It's Scientific Notation! Scientific Notation.
Floating Point Numbers
Copyright © Cengage Learning. All rights reserved.
SCIENTIFIC NOTATION LESSON 19.
Scientific notation Coordinate algebra.
Scientific Notation.
Scientific Notation Students should be able to convert regular notation and scientific notation while following the rules of sig figs.
Scientific Notation Exponent Unit.
What does science have to do with math???
SCIENTIFIC NOTATION.
Scientific Notation.
And how they make life easier!
Writing Numbers in Scientific Notation:
Quantitative Measurements
Scientific Notation (small numbers)
REALLY BIG & REALLY small Numbers
Scientific Notation.
Definition of Let b be a nonzero real number. Then,
Scientific Notation.
Scientific Notation Ch. 3.1.
Lesson 6.9: Scientific Notation
Complete the Following Table
SCIENTIFIC NOTATION.
Standard and Scientific Notation
Scientific Notation.
How wide is our universe?
How wide is our universe?
Unit 1: Matter & Measurement
Scientific Notation CP Chemistry.
Unit 3 (8.EE.3,4) Vocabulary.
Chapter Ten Exponents and Scientific Notation
Section 4.3 Scientific Notation.
Scientific Notation Objective: Students will read and write numbers in
Scientific Notation.
Multiply & Divide with Scientific Notation
The ability to write all numbers between 1 and 10.
Scientific Notation.
Standard Notation to Scientific Notation
Multiplying and Dividing in Scientific Notation
Math 2-9: Warm-up.
Objective - To multiply decimals.
Scientific Notation WCHS Chemistry.
A short form of writing very large or very small numbers
Representation of real numbers
Scientific Notation.
Scientific Notation EXPONENTS X10.
Scientific Notation Very large numbers and very small numbers are written in scientific notation.
Warm Up Multiply 15 x x x 10, x x x Solution 15, ,
From the Previous Table…
Chapter3 Fixed Point Representation
Scientific Notation THE LOGICAL APPROACH.
Scientific notation: positive exponent
Scientific Notation Students will learn the uses of Scientific Notation and apply the lesson into their studies.
Scientific Notation WCHS Chemistry.
Presentation transcript:

Formatting Output Slides by Dr. Heuring In the current version of Java you may format your output using a couple of classes. Classes are in java.text.* package. DateFormat DecimalFormat MessageFormat SimpleDateFormat

Formatting a Decimal DecimalFormat f = new DecimalFormat("###,###.00"); double value1 = 1224.567, value2=0.4, value3 = -10000.0; System.out.println("Value1 = "+f.format(value1)); System.out.println("Value2 = "+f.format(value2)); System.out.println("Value3 = "+f.format(value3)); Output: Value1 = 1,224.57 Value2 = .40 Value3 = -10,000.00

The DecimalFormat Symbols 0 – digit or 0 if no digit. # -- digit or blank if absent . – decimal separator - -- minus sign , -- Grouping Separator E – separator for mantissa and exponent in scientific notation ; -- separates positive and negative subpatterns % -- multiply by 100 and show as a percnetage

Another Example for Decimals DecimalFormat f2 = new DecimalFormat( " ###,##0.00;-###,##0.00"); System.out.println("Value1 = "+f2.format(value1)); System.out.println("Value2 = "+f2.format(value2)); System.out.println("Value3 = "+f2.format(value3)); Output Value1 = 1,224.57 Value2 = 0.40 Value3 = -10,000.00