Java List of If Else Programming Exercises
Java List of If Else Programming Exercises
1. Write a Java program to accept two integers and check whether they are equal or not
2. Write a Java program to check whether a given number is even or odd
3. Write a Java program to check whether a given number is positive or negative.
14. Write a Java program to input marks of five subjects Physics, Chemistry, Biology,
Mathematics and Computer. Calculate percentage and grade according to following:
Percentage >= 90% : Grade A
Percentage >= 80% : Grade B
Percentage >= 70% : Grade C
Percentage >= 60% : Grade D
Percentage >= 40% : Grade E
Percentage < 40% : Grade F
15. Write a Java program to input basic salary of an employee and calculate its Gross salary
according to following:
Basic Salary <= 10000 : HRA = 20%, DA = 80%
Basic Salary <= 20000 : HRA = 25%, DA = 90%
Basic Salary > 20000 : HRA = 30%, DA = 95%
16. Write a Java program to input electricity unit charges and calculate total electricity bill
according to the given condition:
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
17. The rate of interest given to customer by bank depends on the age and gender of the
customer. Write a program in Java that takes as input age and gender of customer and generates
the rate of interest to be given to that customer by the bank as per the conditions given below
18 – 50 Male 6.00 %
18 – 50 Female 6.5 %
50 + Male 6.75 %
50 + Female 7.5 %
13. Write a program in Java to print the electricity bill of the customer based on the meter
readings given by the user. Program accepts the name and the readings given by the user,
computes the bill amount and prints the bill accordingly as:
MPSEB
Bill for the month of : _________ Name of Consumer : ___________
Fixed Rent (A) : ______________ Total Units consumed : _________
Amount for consumed Units (B) : _________ Total Bill Amount (A + B) :
________
Fixed amount is Rs. 250 /- per month.