# Chap3 - Chapter 3 Numerical Data Topics Variables Numeric...

This preview shows pages 1–9. Sign up to view the full content.

Chapter 3 Numerical Data

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Topics Variables Numeric data types Assignment Expressions
Numeric Data and Operations So far, our programs have used only String data It is common to use computers for numeric calculations We can write literal numbers into our programs - just write the number We need a way to store numeric data - variables

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Variables In mathematical expressions, we often use x and y to represent unknown values and to make a placeholder for many different values y = x 2 + 5 A variable is used in a similar way in a program A variables has a Java identifier for a name.
Variables In the last chapter, we declared variables whose location stored the address of an object Now we need to learn to declare variables to store numeric data. A declaration sets aside memory locations to store data values. These memory locations are called variables , and x and y are the names we associate with the memory locations. As before, we need to say what kind of data the variable represents.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Variables A variable has three properties: A memory location to store the value. The type of data stored in the memory location. The name used to refer to the memory location.
Variable Declarations The syntax for declaring variables is <data type> <variables>; where <variables> is a sequence of identifiers separated by commas. Every variable we use in a program must be declared.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Numeric Types There are six numeric data types in Java: We nee to be able to use two basic kinds of numbers. We have several types for each kind of number to allow for different ranges
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 29

Chap3 - Chapter 3 Numerical Data Topics Variables Numeric...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online