If else exercises

If else exercises

List of if...else Java programming exercises

  1. Java program to find maximum between two numbers.
  2. Java program to find maximum between three numbers.
  3. Java program to check whether a number is negative, positive or zero.
  4. Java program to check whether a number is divisible by 5 and 11 or not.
  5. Java program to check whether a number is even or odd.
  6. Java program to check whether a year is leap year or not.
  7. Java program to check whether a character is alphabet or not.
  8. Java program to input any alphabet and check whether it is vowel or consonant.
  9. Java program to input any character and check whether it is alphabet, digit or special character.
  10. Java program to check whether a character is uppercase or lowercase alphabet.
  11. Java program to input week number and print week day.
  12. Java program to input month number and print number of days in that month.
  13. Java program to count total number of notes in given amount.
  14. Java program to input angles of a triangle and check whether triangle is valid or not.
  15. Java program to input all sides of a triangle and check whether triangle is valid or not.
  16. Java program to check whether the triangle is equilateral, isosceles or scalene triangle.
  17. Java program to find all roots of a quadratic equation.
  18. Java program to calculate profit or loss.
  19. Java program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. Calculate pass or fail,percentage and grade according to following:
  20. Percentage >= 90% : Grade A
    Percentage >= 80% : Grade B
    Percentage >= 70% : Grade C
    Percentage >= 60% : Grade D
    Percentage >= 40% : Grade E
    Percentage < 40% : Grade F
    

  21. Java program to input basic salary of an employee and calculate its Gross salary according to following.
  22. Basic Salary <= 10000 : HRA = 20%, DA = 80%
    Basic Salary <= 20000 : HRA = 25%, DA = 90%
    Basic Salary > 20000 : HRA = 30%, DA = 95%
    

  23. Java program to input electricity unit charges and calculate total electricity bill according to the given condition.
  24. For first 50 units Rs. 0.50/unit
    For next 100 units Rs. 0.75/unit
    For next 100 units Rs. 1.20/unit
    For unit above 250 Rs. 1.50/unit
    An additional surcharge of 20% is added to the bill