Lab Sheets 5 & 6: Java Control Statements

Part 1: Sequential Flow (Sequence Logic)
- Write a Java program that takes two numbers as input and prints their sum, difference, product, and quotient in sequence.
Part 2: Conditional Statements (Selection Logic)
If-Else Statement:
Write a program that checks if a given number is even or odd.
Write a program that determines the largest among three numbers.
Switch Statement:
- Write a program that takes a day number (1-7) and prints the corresponding day name (e.g., 1 → "Monday").
Part 3: Loops (Iteration Logic)
For Loop:
Write a program to print the first 10 natural numbers.
Write a program to calculate the factorial of a number.
While Loop:
Write a program to print all even numbers between 1 and 20.
Write a program to find the sum of digits of a given number.
Do-While Loop:
Write a program that keeps asking the user to enter a number until they enter a negative number.
Write a program to print the multiplication table of a number using
do-while.
Challenge Problems
Nested Control Structures:
Write a program to check if a number is prime or not.
Write a program to print the Fibonacci series up to 'n' terms.
Pattern Printing:
Use nested loops to print the following patterns:
* ** *** **** *****1 12 123 1234 12345




