100% found this document useful (1 vote)
2K views

Java List of If Else Programming Exercises

The document provides 16 Java programming exercises involving if-else statements to check conditions such as equality of integers, even/oddness, positive/negative values, divisibility, leap years, voting eligibility, uppercase/lowercase conversion, alphabet/number identification, maximum of three numbers, temperature-based messages, vowel/consonant identification, and profit/loss calculation. Additional exercises include calculating student grades and employee salaries based on percentages and allowances. Further exercises calculate electricity bills based on consumption tiers and interest rates based on customer age and gender. The final exercise provides a template to print an electricity bill.

Uploaded by

Amx
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views

Java List of If Else Programming Exercises

The document provides 16 Java programming exercises involving if-else statements to check conditions such as equality of integers, even/oddness, positive/negative values, divisibility, leap years, voting eligibility, uppercase/lowercase conversion, alphabet/number identification, maximum of three numbers, temperature-based messages, vowel/consonant identification, and profit/loss calculation. Additional exercises include calculating student grades and employee salaries based on percentages and allowances. Further exercises calculate electricity bills based on consumption tiers and interest rates based on customer age and gender. The final exercise provides a template to print an electricity bill.

Uploaded by

Amx
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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.

4. Write a Java program to check whether a number is divisible by 5 and 11 or not.


5.  Write a Java program to find whether a given year is a leap year or not
6. Write a Java program to read the age of a candidate and determine whether it is eligible
for casting his/her own vote.
7.  Write a Java program to convert upper case character to lower case.
8. Write a Java program to convert lower case character to upper case.

9. Write a Java program to check whether a character is alphabet or not.


10. Write a Java program to find the largest of three number
11. Write a Java program to read temperature in centigrade and display a suitable message
according to temperature state below :
Temp < 0 then Freezing weather 
Temp 0-10 then Very Cold weather
Temp 10-20 then Cold weather
Temp 20-30 then Normal in Temp 
Temp 30-40 then Its Hot 
Temp >=40 then Its Very Hot
12. Write a Java program to check whether an alphabet is a vowel or consonant.
13. Write a Java program to calculate profit and loss on a transaction.

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

Age Group Gender Rate of Interest

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.

METER READING CHARGE / UNIT


First 200 Units 65 paise
201 – 400 Units 80 paise
Above 400 Units 120 paise

You might also like