Java Lesson: Data Types/Vars
Last Updated: 2/11/2013
mr Hanley

Objective: The objective of this lesson is to introduce the student to data storage inside computer programs. The student should know that; all data in a computer is stored in a binary format (either 1’s or 0’s), numbers are stored as either integers or floating point values, there are booleans and chars, which are integers that represent an ASCII code. Student should know that a series of ASCII codes (array) make up a String. Student should be able to declare and assign these types of variables.

Information in a computer is stored in a _____________________________ format.
Computers spend all day interacting with data; crunching numbers, transferring web sites from servers to clients, rendering 3D images of buildings and space ships.

Programmers must know how to build a data model to represent the entity they are asking the computer to process.

We need to know the options for representing data using java.

First, computers store data as a series of ________ and _________ states.

These states can be described using the ______________ number system.

In the binary number system, each digit is a power of 2.

For example, the following sequence of on and off states represents the decimal (base 10) number 23

27=128	26=64	25=32	24=16	23=8	22=4	21=2	20=1

What sequence of on/off states would be used to represent the number 2010?

Computers utilize these 4 basic types

A fifth basic type can be thought of by combining chars using an ____________
This type is called a _____________________

Data Type Ranges

Java recognizes the types shown in the table below.

TYPE	CONTAINS	SIZE	MAX	MIN
boolean	boolean value	8 bits	true	false
char	Unicode char	16 bits	\uFFFF	\u0000
byte	signed integer	8 bits	127	-128
short	signed integer	16 bits	32767	-32768
int	signed integer	32 bits	2147483647	-2147483648
long	signed integer	64 bits	8.223372 E +18	-9.223372 E +18
float	floating point	32 bits	3.402823 E +38 1.402398 E -45	-3.402823 E +38 -1.402398 E -45
double	floating point	64 bits	1.797693 E +308 4.940656 E -324	-1.797693 E +308 -4.940656 E -324

Here are some variable naming rules;

Let’s practice declaring and assigning variables
public class VarPractice {
public static void main(String[] args) {
//Declare variables to hold hourly salary at taco bell and assign 8.25
//Declare the variables necessary in the following problems

Declare variables and assign values to store 5 temperatures that can range from –15 to 120 and can have fractional parts(decimals).

Store 5 different temperatures

Declare another variable that can store decimals and assign into it the average of the 5 temperatures from above.
judicious

Declare a variable that can store the amount of money that bananas cost per pound($ and cents)

Declare a variable that can store the number of lbs of bananas a person will purchase (fractional possible)

Declare and assign a variable the amount of money owed by the banana purchaser by using the variables above

Set up boolean variables to keep track of whether or not a student has taken the following courses;
Design and Drawing for Production, Design and Drawing for Engineering, Digital Electronics, Computer Integrated Manufacturing, Java and AP Computer Science.

Assign DDE, DDP, CIM and Java to true and Digital and AP Computer Science to false

Declare variables to keep track of the number of students in homeroom 134, 129 and 140. Assign them values

Assign two points and come up with the distance between the points and the midpoint

THE ASCII TABLE(American Standard Code for Information Interchange)

Extended ASCII (not standard)

Write out your first name followed by a space and then your last name (capitalize the first letter of your first and last names) Then look up and write the ASCII code for each letter and the space!
For Example,	m	r	space	H	a	n	l	e	y

109	114	32	72	97	110	108	101	121