LIST OF JAVA PROGRAMS related with
Conditional Statement
1. Write
a JAVA program to accept two integers and check whether they are equal or not.
Test Data : 15 15
Expected Output :
Number1 and Number2 are equal
Expected Output :
Number1 and Number2 are equal
2. Write
a JAVA program to check whether a given number is even or odd.
Test
Data : 15
Expected Output :
15 is an odd integer
Expected Output :
15 is an odd integer
3. Write a JAVA program to check whether a given number is positive or negative. Test Data : 15
Expected Output :
15 is a positive number
4. Write
a JAVA program to find whether a given year is a leap year or not.
Test Data : 2016
Expected Output :
2016 is a leap year.
Test Data : 2016
Expected Output :
2016 is a leap year.
5. Write
a JAVA program to read the age of a candidate and determine whether it is
eligible for casting his/her own vote. Test Data : 21
Expected Output :
Congratulation! You are eligible for casting your vote.
Expected Output :
Congratulation! You are eligible for casting your vote.
6. Write
a JAVA program to read the value of an integer m and display the value of n is
1 when m is larger than 0, 0 when m is 0 and -1 when m is less than 0.
Test Data : -5
Expected Output :
The value of n = -1
Test Data : -5
Expected Output :
The value of n = -1
7.
Write a JAVA program to accept the height of a person in centimeter and
categorize the person according to their height.
Test Data : 135
Expected Output :
The person is Dwarf.
Test Data : 135
Expected Output :
The person is Dwarf.
8. Write
a JAVA program to find the largest of three numbers.
Test
Data : 12 25 52
Expected Output :
1st Number = 12, 2nd Number = 25, 3rd Number = 52
The 3rd Number is the greatest among three
Expected Output :
1st Number = 12, 2nd Number = 25, 3rd Number = 52
The 3rd Number is the greatest among three
9. Write
a JAVA program to accept a coordinate point in a XY coordinate system and
determine in which quadrant the coordinate point lies.
Test
Data : 7 9
Expected Output :
The coordinate point (7,9) lies in the First quadrant.
10. Write a JAVA program to find the eligibility of admission for a professional course based on the following criteria: Marks in Maths >=65
Marks in Phy >=55
Marks in Chem>=50
Total in all three subject >=180
or
Total in Math and Subjects >=140
Test Data : Expected Output :
The coordinate point (7,9) lies in the First quadrant.
10. Write a JAVA program to find the eligibility of admission for a professional course based on the following criteria: Marks in Maths >=65
Marks in Phy >=55
Marks in Chem>=50
Total in all three subject >=180
or
Total in Math and Subjects >=140
Input the marks obtained in Physics :65
Input the marks obtained in Chemistry :51
Input the marks obtained in Mathematics :72
Expected Output :
The candidate is eligible for admission.