> For the complete documentation index, see [llms.txt](https://codewithmeiy.gitbook.io/core-java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codewithmeiy.gitbook.io/core-java/test-your-knowledge/control-statements.md).

# Control Statements

Let's test your knowledge on if-else and switch statements in Java with the following problem statements:

1. Write a Java program to check if a given number `num` is positive, negative, or zero using if-else statements.
2. Create a Java program to determine whether a given year `year` is a leap year or not using if-else statements.
3. Write a Java program to find the maximum of three numbers `a`, `b`, and `c` using if-else statements.
4. Develop a Java program to check if a given character `ch` is a vowel or a consonant using if-else statements.
5. Implement a Java program to check if a given number `num` is even or odd using if-else statements.
6. Write a Java program to determine the grade of a student based on their percentage `percentage` using if-else statements.
7. Create a Java program to find the largest among three numbers `num1`, `num2`, and `num3` using if-else statements.
8. Develop a Java program to determine if a given integer `number` is divisible by both 2 and 3 using if-else statements.
9. Write a Java program to check if a given string `str` is palindrome or not using if-else statements.
10. Implement a Java program to determine the day of the week based on a given number `dayNumber` (1 for Monday, 2 for Tuesday, etc.) using switch statements.
11. Develop a Java program to print the name of the month based on a given number `monthNumber` (1 for January, 2 for February, etc.) using switch statements.
12. Write a Java program to calculate the number of days in a given month `month` using switch statements.
13. Create a Java program to print the name of a shape based on a given number `shapeNumber` (1 for Circle, 2 for Square, 3 for Triangle, etc.) using switch statements.
14. Implement a Java program to calculate the total cost of purchasing `quantity` items at `price` each, including a sales tax of 8%, using if-else statements.
15. Write a Java program to determine the eligibility of a person to vote based on their age `age` using if-else statements.
16. Develop a Java program to calculate the discount percentage based on the total purchase amount `totalAmount` using if-else statements.
17. Create a Java program to determine the season based on a given month `month` using switch statements.
18. Implement a Java program to calculate the BMI (Body Mass Index) based on the weight `weight` in kilograms and height `height` in meters using if-else statements.
19. Write a Java program to determine the largest among three numbers `x`, `y`, and `z` using nested if-else statements.
20. Develop a Java program to assign a grade to a student based on their marks `marks` in a subject using if-else statements.

These problems cover various scenarios where you'll need to use if-else and switch statements in Java to solve different types of problems.
