65-lecture04 - Computer Science 65 Intro to CS February 5,...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Science 65 Intro to CS February 5, 2008 Java Fundamentals Keyboard Input
Background image of page 1

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

View Full DocumentRight Arrow Icon
Announcements Assignment #2 due Thursday Hand in before class Read Chapter 2 Java Basics 2.1 – 2.7 (pages 27-66) 2.9 – 2.15 (pages 68-98)
Background image of page 2
Today’s Lecture Java Fundamentals Java is a tool “How can we use Java to do what we want to do” What are Java’s syntactic rules?
Background image of page 3

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

View Full DocumentRight Arrow Icon
Primitive Data Types Every variable is assigned a _____________ Primitive data types are “built in” the java programming language Not derived from classes Java has 8 primitive data types
Background image of page 4
Declaring Variables In java, every variable must first be declared before it can be used int day; char middleInitial; double amountOfMoney; //after variables are declared, they //can be used in the program day = 7; middleInitial = ‘M’; amountOfMoney = -705.54;
Background image of page 5

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

View Full DocumentRight Arrow Icon
Declaring Variables Variables can also be declared and initialized on the same line of code int day = 7; char middleInitial = ‘M’; double amountOfMoney = -705.54; //after variables are declared, they //can be used in the program amountOfMoney = -705.53 + .02;
Background image of page 6
Numeric Data Types byte 1 byte Integers in the range -128 to +127 short 2 bytes Integers in the range of -32,768 to +32,767 int 4 bytes Integers in the range of -2,147,483,648 to +2,147,483,647 long 8 bytes Integers in the range of -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 float 4 bytes Floating-point numbers in the range of ±3.410E-38 to ±3.410E38 , with 7 digits of accuracy double 8 bytes Floating-point numbers in the range of ±1.710E-308 to ±1.710E308 , with 15 digits of accuracy
Background image of page 7

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

View Full DocumentRight Arrow Icon
Integer Data Types ________ _________ __________ and ________ are all integer data types. Integer data types cannot hold numbers that have a decimal point in them. int value; value = 5.5; // error!
Background image of page 8
Floating Point Data Types In Java there are two data types that can represent floating-point numbers. ________________ - also called single precision (7 digits of accuracy). ________________ - also called double precision (15 digits of accuracy).
Background image of page 9

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

View Full DocumentRight Arrow Icon
double myVariable = 4,532.124;
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 41

65-lecture04 - Computer Science 65 Intro to CS February 5,...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online