Searching the Java API - find the Java API and then find the Math class. What methods are available?
Continue work on Section 4 Lesson 3: Data Types and Operators slides
Complete Section 4 Lesson 3: Programming with Data Types and Operators practice on school loop
Show me your TriangleArea calculator - prob #1, FieldTrip calculator - prob #3, and the rest of the questions. Do the math calculations - prob #2 only after you have finished problems 1 & 3.
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
Problem 2:For the MathPractice problem use the following values for the variables for A-C
double x = 3.0;
double y = 5.0;
double z = 4.0;
double answer = 0.0;
For problems D-F make y=2.0 Your output should show the following for each problem:
Problem A.
X = 3.0 - show the actual values of all variables used in the formula, in this case only X
The answer is 3.848701079585163
Data Type Conversions - Type Casting - Implicit and Explicit
Implicit Type Casting - Java will automatically (implicitly) make the following conversions:
Byte > Short > Int > Long > Float > Double
In all of these conversions you are moving from a smaller data type to a larger data type thus no data is lost and java will perform this operation automatically (implicitly).
int i = 100;
long l = i;
float f = l;
System.out.println("Int value "+i);
System.out.println("Long value "+l);
System.out.println("Float value "+f);
If you want to convert a Double to an Int Java will not perform this operation automatically because it would result in the loss of data but you can force Java to make the conversion if you Explicitly make the conversion.
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.