0% found this document useful (0 votes)
7 views1 page

Java Lab3 Handout

The document outlines Java Lab 3 focused on practicing conditional statements such as if, if-else, nested if, and switch. It includes interactive activities like a movie ticket checker, electricity bill calculator, and tea shop menu based on user input. Additionally, it provides a quick recap of the syntax for these conditional statements.

Uploaded by

MirHazar Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Java Lab3 Handout

The document outlines Java Lab 3 focused on practicing conditional statements such as if, if-else, nested if, and switch. It includes interactive activities like a movie ticket checker, electricity bill calculator, and tea shop menu based on user input. Additionally, it provides a quick recap of the syntax for these conditional statements.

Uploaded by

MirHazar Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Java Lab 3 – Conditional Statements

Objective: Practice if, if-else, nested if, and switch.

Quick Recap (Cheat Sheet) Interactive Activities (Tasks)

if (condition) {
// code
1. Movie Ticket Checker
} else if (anotherCondition) { Read integer age. Print exactly: "Free Entry" if age <
// code 5; "Half Ticket" if age is between 5 and 12
} else { (inclusive); otherwise print "Full Ticket".
// code
}

switch(value) {
2. Electricity Bill
case 'S': // code; break;
Input units consumed (integer). Use conditional logic
case 'M': // code; break;
to print one of: "Low usage" (<100), "Medium
default: // code;
usage" (100–300 inclusive), or "High usage" (>300).
}

Predict & Run (Puzzle)

int x = 7; 3. Tea Shop Menu


if (x % 2 == 0) Read a character size (S, M, L). Print the price: S ->
System.out.println("Even"); 50; M -> 80; L -> 120. Use switch on the
else if (x % 3 == 0) character.
System.out.println("Divisible by 3");
else
char size = 'M';
System.out.println("Other"); // What will this print?
switch (size) {
case 'S': System.out.println(50); break;
case 'M': System.out.println(80); break;
case 'L': System.out.println(120); break;
Notes / Output default: System.out.println("Invalid size");

MK Tech – Java Lab Handout • Single-page, print-ready (A4)

You might also like