Class 15 - Types and Expressions 10/15/2009 Click to edit...

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

View Full Document Right Arrow Icon
12/4/09 Click to edit Master subtitle style Types and Expressions 10/15/2009 Matthew Hashim 11
Background image of page 1

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

View Full DocumentRight Arrow Icon
MGMT 290D 12/4/09 Goals for Today n Use variables and constants n Understand the difference between Java’s fundamental and class types 22
Background image of page 2
MGMT 290D 12/4/09 Types and Expressions n Alice and Java allow you to send messages to objects n Java uses the double type to represent real numbers n Some topics to cover ¨ Declaring variables and constants ¨ Constructing expressions ¨ Additional capabilities of printf() ¨ Methods libraries provided by Java 33
Background image of page 3

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

View Full DocumentRight Arrow Icon
MGMT 290D 12/4/09 Introductory Example: Months from Month Numbers n Elements of the user story ¨ Prompt the user for a month number (1-12) ¨ Read the number from the keyboard ¨ Compute the corresponding month name ¨ Display the month abbreviation, with descriptive labels n Derive objects from noun phrases in the user story n Derive methods from verb phrases in the user story n Features of a String object useful to this program ¨ Each character in a String has a numerical index ¨ A single character or substring is accessed by index 44
Background image of page 4
MGMT 290D 12/4/09 Introductory Example: Months from Month Numbers (continued) n Create your algorithm and flowchart on separate pieces of paper 55
Background image of page 5

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

View Full DocumentRight Arrow Icon
MGMT 290D 12/4/09 Introductory Example: Months from Month Numbers (continued) n Strategy for computing monthAbbrev from a number ¨ Build a String ( monthTable ) to store abbreviations ¨ Access the month abbreviation using String index n Method used: aString.substring(start,stop) ¨ start = (monthNumber - 1) * 3; stop = start + 3 ¨ Example: “Jan” n Every variable in a Java program has a type ¨ Primitive types: 8 types that store numbers; e.g., int ¨ Reference types: refer to objects; e.g., String 66
Background image of page 6
MGMT 290D 12/4/09 Introductory Example: Months from Month Numbers (continued) 77
Background image of page 7

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

View Full DocumentRight Arrow Icon
MGMT 290D 12/4/09 Introductory Example: Months from Month Numbers (continued) 88
Background image of page 8
MGMT 290D 12/4/09 Introductory Example: Months from Month Numbers (continued) 99
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 29

Class 15 - Types and Expressions 10/15/2009 Click to edit...

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

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