Data Types in Programming: Integer to Boolean
Understand how computers organize information and why data types matter in CSEC IT!
Why Do Data Types Matter?
Memory Allocation
The computer needs to know how much space to set aside for each piece of data. A whole number (like 42) takes up less memory than a long sentence (like "The quick brown fox jumps over the lazy dog").
Allowed Operations
Data types tell the computer what operations are allowed. You can multiply two numbers, but you can't multiply two names. This prevents logical errors in programs.
Try to drag a "Word" into the "Math Calculator." See what happens when you use the wrong data type!
Math Calculator
Accepts: Integer, Float
Integer: The Whole Numbers
Integer
Definition: Positive or negative whole numbers with no fractional parts.
CSEC Examples: Age (15), Number of students (30), Year (2026)
Range: Typically -32,768 to 32,767 (in some systems)
Click only the integers to build a "Digital Tower"!
Your integer tower will appear here...
Real / Float: The Decimals
Float (Real)
Definition: Numbers that contain fractional parts or decimal points.
CSEC Examples: Price ($19.99), Weight (150.5 lbs), GPA (3.8)
Precision: Used for measurements and money where exact values matter
Drag the slider to see how precision changes from Integer to Float with scientific measurement!
Scientific Measurement Example:
In chemistry, we measure 1.0000g (float) not 1g (integer) because precision matters!
String vs. Character: Handling Text
Character
Definition: A single letter, number, or symbol (e.g., 'A', '$', '7')
Memory: Typically 1 byte per character
String
Definition: A sequence or "string" of characters (e.g., "Jamaica", "CSEC IT 2026")
The "Number as Text" Trap: Phone numbers and ZIP codes are stored as Strings, not Integers (we don't do math with them!)
Drag individual "Character" blocks together to form a "String" word!
Drag characters here to build a string...
Boolean: The Logical Choice
Boolean
Definition: Can only hold one of two values: True or False (or Yes/No, 1/0)
The "Switch" Metaphor: Like a light switch - it's either ON or OFF
CSEC Examples: Is_Graduate, Fees_Paid, Game_Over, Password_Correct
Toggle the switches to see how Boolean values work in programming!
Boolean Values in Code:
boolean feesPaid = false;
boolean gameOver = false;
Type Compatibility & Errors
Data Type Mismatch
What happens when you try to save "ABC" into an Integer variable? You get a Runtime Error or Type Error!
Type Casting
Converting one data type to another (e.g., changing the string "5" into the integer 5). This must be done carefully to avoid data loss.
Find the data type error in this code! Click on the line with the bug.
Hint: Phone numbers should be stored as strings, not integers!
Knowledge Check: The Data Type Challenge
Select the correct data type for each piece of data!
| Data | Select Data Type |
|---|---|
| 30.5 | |
| "Password123" | |
| False | |
| 500 | |
| 3.14159 |
Exam Scenario
"Which data type is most appropriate for storing a student's middle initial? Why?"
