2_Java Fundamentals_2024
2_Java Fundamentals_2024
RECAP
Connect to prior learning
Quiz time
STIMULUS / STARTER
Stimulus: The Recipe Ingredients
Imagine you're following a recipe to bake cookies. In the recipe, you
have a list of ingredients and their quantities. Now, let's relate this
to programming:
1.Variables: Think of variables as containers for storing information,
much like the ingredients listed in a recipe. Each variable can hold
different types of data, just like each ingredient in a recipe has its
own unique properties (e.g., flour, sugar, eggs, butter).
2.Tokens: In programming, tokens are like the individual steps or
instructions in a recipe. Each token serves a specific purpose and
contributes to the overall process of executing a program.
How do you
store these
ingredients in
Java?
public class CookieRecipe {
public static void main() {
// Declare variables for ingredients and quantities
String flour = "2 cups";
String sugar = "1 cup";
int eggs=2;
double butter = 0.5; // in cups
Cookie Recipe:
- Flour: 2 cups
- Sugar: 1 cup
- Eggs: 2
- Butter: 0.5 cups