PART A: Code Completion
Assessment
Instruction: Fill in the missing parts.
Write your answer:
1. int x = 5;
int y = 10;
______ = x + y;
System.out.println(______ );
2. double myDouble = 9.78;
int myInt = (___) myDouble;
3. int x = 10;
x ___ 5; // same as x = x + 5
4. boolean isJavaFun = ___;
PART B: Debug the Code
Instruction: Find and correct the errors.
public class Test {
public static void main(String[] args) {
int num = 5.5;
System.out.println(num)
}
}
Guide Questions:
What is wrong with the data type?
What syntax error is present?
PART C: Mini Challenge
Instruction: Create a simple Java program.
Problem:
Write a program that:
Stores:
number of items = 10
price per item = 15.5
Calculates total cost
Prints result like:
o
o
Total cost is: ___
Use type casting if needed
Add a currency symbol
PART D: Think & Apply
1.
2.
3.
4.
Why is double more precise than float?
When should we use int vs long?
What happens if you forget type casting?
Why are boolean values important in
decision-making?
What is the difference between:
= and ==
&& and ||