Java Programming

 

     

 

Wednesday, January 22nd

 

Review of the Vehicle and VehicleDriver Classes - Class Warm-up

Review of Data Types - What are the three most commonly used primitive data types?

Do you know how many bits are in a byte? So how many bits are in this data type (8 bytes) which is the largest integer type? Can we use this information to complete part of the vocabulary regarding data primitive types.

Review of the Student Class 4-2 - the advantage of using the PDF version of the lesson - you can copy and paste!

Type Casting - Explicit vs Implicit - slides 38 - 46
In Java implicit type conversions occur automatically, no work required on your end because you are moving from a smaller data type to a larger data type (int to double - no loss of data)
Explicit type conversions require that you use the type casting operator because you are moving from a larger data type to a smaller data type and data will be lost. Java wants to make sure you know what you are doing and forces you to Explicitly convert the data type using the casting operator (double to int - data is lost)

Type Casting - this you should know about.
Create a JavaPractice project and then a JavaPractice class - use this file just to try out a small blocks of java code - have this open as you read through the text and try out some of the code examples they show. Now try the Type Casting code - copy and paste.
Variable Names - slide 15-16. - don't be old school - use names that make sense and explain what is happening in the code.
Constant Names - ALL CAPS and use the keyword final before the type - final double PI = 3.141592; Once declared the value of PI cannot be changed.

Section 4: Lesson 3 - Data Types and Operators Vocabulary:
- Named primitive or object storage mechanisms defined in a program. The assigned value may or may not (constants) change.
- Symbols are used to do addition, subtraction, multiplication, division, and modular arithmetic in math expressions and formulas.
- The group of Java data types that do not use the keyword new when declared or initialized. Primitive Data Types store the value in the same place in memory as the variable name.
- The smallest java primitive type (1 byte) that can hold an integer value.
- This data type (8 bytes) is the largest integer type.
- The formatting and naming standards that most programmers follow.
- This Java primitive data type (4 bytes) can hold integer values.
- This Java primitive data type (8 bytes) is the largest primitive that can hold a decimal value.
- When a variable is assigned a value for the first time.
- This Java primitive data type (4 bytes) can be initialized with a decimal number preceding letter f. Example: float x = 3.5f;
- Can be any number, text, or other information that represents a value; used to initialize a primitive type.
- A Java statement when a variable is defined but not necessarily assigned a value. Example: int x;
- This word describes the mathematical precedence that a variable has in a Java program.
- A java primitive data type (2 bytes) that can hold single character values. Example: “a”, “#”, or “X”
- Used to describe the block of code where a variable exists in a program. A block of code is denoted by {}.
- The process of explicitly modifying one data type to become a different data type.
- A concept where a number is always rounded down to the nearest integer.
- The equals sign “=” used in a Java statement to assign a value to a variable.
- The process of modifying one data type to become a different data type, this may be implicit or explicit.
- A Java primitive data type (2 bytes) that holds integer numbers within a shorter range than an int. - A one-bit java primitive type that can hold the value true or false.

Review - primitive data types, variableNames, declaring and initializing variables, variable scope

0b0101, 0x56AC, 56.304f

Operator Precedence + - / * % ++ --
How can you override precedence?
Modulus operator %
Pre-increment vs Post-increment
implicit type conversions - smaller into bigger is OK but the reverse is NOT allowed.
Using the Java API (or Google)
Relational Operators
Logical Operators

Complete Section 4 Lesson 3: Data Types and Operators slides
Complete Section 4 Lesson 3: Data Types and Operators practice
Show me your TriangleArea calculator - prob #1, FieldTrip calculator - prob #3, and the rest of the questions. The math calculations - prob #2 is extra credit.

The final output for the Triangle Area should look like this: The area of a triangle with a base of ____ and a height of ___ is _____. Thank you for using the Triangle Area Calculator. This program is brought to you by

The final output for the Field Trip program should look like this:Your field trip with ______people will require ______busses and _____ vans. Thanks for using the field trip calculator. This program was brought to you by



 

Homework

Install Eclipse on your home computer if you would like to be able to work on your java at home.

 

What

Objectives for Section 4 Lesson 2
In this lesson, you will learn how to:
• Describe the general form of a Java program
• Use variables and apply the IF and FOR statements
• Create a block of code
• Recognize Java keywords

 

Why

Eclipse is an efficient and easy to use a development environment for creating Java programs. It is a well known tool by many Java programmers and is used in many development environments.
Learning Eclipse in this lesson will give you additional skills with tools used in the Java programming space.

 

How

By completing the slides, quiz and practice exercises.