0% found this document useful (0 votes)
6 views21 pages

Java Basics Lesson Plan Overview

This lesson plan covers the basics of Java programming, including syntax, data types, conditional statements, loops, and arrays. It includes practical exercises for students to apply their knowledge, such as writing programs that utilize arrays and conditional logic. The document also outlines homework assignments to reinforce learning through variable declaration, user input, and data processing.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views21 pages

Java Basics Lesson Plan Overview

This lesson plan covers the basics of Java programming, including syntax, data types, conditional statements, loops, and arrays. It includes practical exercises for students to apply their knowledge, such as writing programs that utilize arrays and conditional logic. The document also outlines homework assignments to reinforce learning through variable declaration, user input, and data processing.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Java Basics

Revision & Praactice


Nikoloz Kiladze
Newton Free School
LESSON PLAN

[Link] and apply Java basic syntax


2. Use variables and data types correctly
3. Write conditional statements (if-else)
4. Implement repetition using for and while loops
5. Manipulate arrays for storing data
Common Primitive Data
Type Types Description Example

int Integer (Whole Number) int age = 17;

Decimal (Floating point


double double price = 12.5
number)

char Single character char grade = ‘A’;

boolean true/false boolean isPassed = true

String is not a primitive data type


String name = “Nikoloz”;
Declaring Variables
To declare a variable we write a data type, then
name of the variable.

Using ‘=’ sign we assign/update a value to that


variable.

int score = 85; score = score +


String name = "Luka"; 10;
boolean passed =
true;
Input/Output
To input a variable we need to import Scanner
class and create Scanner object.

import [Link];

Scanner scanner = new Scanner([Link]);


[Link]() //String
[Link]() //Integer...
Conditional Statements
int score = 75;
if (score >= 90) {
[Link]("Excellent!");
} else if (score >= 50) {
[Link]("Passed");
} else {
[Link]("Failed");
}
For Loop
for (int i = 0; i < 5; i++) {
[Link]("Count: " + i);
}

Used when you know how many times to repeat.


Has 3 parts: initialization, condition, update.

How can we make it count backwards?


While Loop
int i = 0;
while (i < 5) {
[Link]("Count: " + i);
i++;
}

Runs while condition is true.


Risk of infinite loop if condition never becomes false.

What happens if we forget i++?


Arrays Overview
int[] marks = {85, 90, 78, 92};
[Link](marks[0]); // 85
marks[2] = 80;

Array stores multiple values of the same type.

What is the index of the elast element?


Index starts from 0
Looping through Arrays
int[] nums = {3, 6, 9, 12};
for (int i = 0; i < [Link]; i++) {
[Link](nums[i]);
}

How [Link] controls iteration?

Calculate the sum of all elements.


Practice
Write a Java program that:
[Link] an array of 5 integers.
[Link] a for loop to print them.
[Link] if-else to print whether each number is even
or odd.
Practice
Write a Java program that:
[Link] user for 5 numbers.
[Link] them in an array.
[Link] and prints the average.
4.(Use Scanner class for input)
Quick Recap

[Link]’s the difference between for and while loops?


[Link] is the index of the first element in an array?
[Link] a condition that checks if variable x is greater
than 10.
[Link] is wrong with this line? → double price =
"10.5";
Quick Recap

[Link]’s the difference between for and while loops?


[Link] is the index of the first element in an array?
[Link] a condition that checks if variable x is greater
than 10.
[Link] is wrong with this line? → double price =
"10.5";
Homework Practice
Part 1 – Variable and Data Type Practice
Create a program called [Link].
[Link] and initialize the following variables:
⚬ String studentName
⚬ int age
⚬ double height
⚬ boolean likesCoding
Print a short introduction using these variables, for
example:
Hello, my name is Ana. I am 17 years old, 1.68 meters
tall, and it is true that I like coding.
Homework Practice
Part 2 – Conditional Logic (if-else)
Ask the user to enter their test score (integer between 0
and 100).
Based on the score, display a message:
90 -100 → Output Excellent
70 - 89 → Output Good
50-69 → Output Pass
Below 50 → Fail
Homework Practice
Part 3 – Using Loops
Use a for loop to print numbers from 1 to 10 and their
squares, e.g.
1→1
2→4
3→9
...
Homework Practice
Part 4 – Arrays and Processing Data
[Link] an array that stores 5 integer values
(hardcode them or take user input).
[Link] all elements using a for loop.
[Link] and print:
⚬ The sum of all elements.
⚬ The average value.
⚬ The largest value.
Hint: Use a variable max initialized to the first element,
then compare inside the loop.
Homework Theory
Read the following pages from the book:

112-116
QA
THANK YOU

You might also like