0% found this document useful (0 votes)
4 views3 pages

Basics, Operators, Conditional Statements

This document provides a comprehensive list of Java programming exercises covering various topics such as basics, operators, typecasting, conditional statements, switch statements, and control flow statements like break and continue. Each section includes specific tasks for users to implement, such as printing personal information, performing arithmetic operations, and utilizing conditional logic. The exercises are designed to enhance programming skills and understanding of Java fundamentals.
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)
4 views3 pages

Basics, Operators, Conditional Statements

This document provides a comprehensive list of Java programming exercises covering various topics such as basics, operators, typecasting, conditional statements, switch statements, and control flow statements like break and continue. Each section includes specific tasks for users to implement, such as printing personal information, performing arithmetic operations, and utilizing conditional logic. The exercises are designed to enhance programming skills and understanding of Java fundamentals.
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

1.

Basics of Java

1. Write a Java program to print your name, age, and city.

2. Write a program to add two numbers entered by the user.

3. Write a program to find the area of a rectangle using length and width.

4. Write a program to convert Celsius to Fahrenheit.

5. Write a program to swap two numbers with using a third variable.

6. Write a program to swap two numbers without using a third variable.

2. Operators in Java

6. Write a program to perform all arithmetic operations on two numbers.

7. Write a program to check whether a number is even or odd using the modulus
operator.

8. Write a program to find the largest of two numbers using relational operators.

9. Write a program to check if a number is positive, negative, or zero.

10. Write a program to calculate simple interest using operators.

11. Write a program to perform all assignment operations on two numbers.

12. Write a program to perform all relational operations on two numbers.

3. Typecasting

11. Write a program demonstrating implicit typecasting (int → double).

12. Write a program demonstrating explicit typecasting (double → int).

13. Convert float value into integer and print both values.

14. Convert integer to byte using typecasting.

15. Write a program to divide two integers and store result in double using casting.

4. Conditional Statements

16. Write a program to find the largest of three numbers.

17. Write a program to check if a number is divisible by 5 and 11.

18. Write a program to check whether a number is a leap year.


19. Write a program to check whether a character is a vowel or consonant.

20. Write a program to check whether a person is eligible to vote.

21. Write a Java program to find the largest of three numbers using nested if

22. Write a program to check:

If a number is positive

Then check if it is even or odd

If the number is negative, print Negative Number

5. Switch Statement

21. Write a program using switch to print the day of the week based on a number.

22. Write a program using switch to perform calculator operations.

23. Write a program using switch to display month name based on month number.

24. Write a program using switch to check whether a character is vowel or


consonant.

25. Write a program using switch to print grade based on marks.

6. break with Conditional Statements

26. Write a program that checks a number and breaks execution if it is negative.

27. Write a program where if a user enters 0, the program stops using break.

28. Write a program using switch where break prevents fall-through between cases.

29. Write a program where if marks are less than 35, break the program with a fail
message.

30. Write a program where input "exit" stops the program using break inside
condition.

7. continue with Conditional Statements

31. Write a program that ignores negative numbers using continue and prints only
positive numbers.

32. Write a program where if the number is divisible by 3, skip printing it using
continue.
33. Write a program to skip printing vowels using continue.

34. Write a program where marks below 35 are skipped using continue.

35. Write a program to skip zero values while processing numbers.

You might also like