0% found this document useful (0 votes)
11 views6 pages

If Esle

The document contains a list of programming exercises focused on using if statements to solve various problems, including finding maximum values, checking number properties, calculating grades, and determining salary based on conditions. Each exercise requires writing a program to implement specific logic and calculations. The exercises cover a wide range of topics suitable for practicing conditional statements in programming.

Uploaded by

aankhoteriaadat
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)
11 views6 pages

If Esle

The document contains a list of programming exercises focused on using if statements to solve various problems, including finding maximum values, checking number properties, calculating grades, and determining salary based on conditions. Each exercise requires writing a program to implement specific logic and calculations. The exercises cover a wide range of topics suitable for practicing conditional statements in programming.

Uploaded by

aankhoteriaadat
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
You are on page 1/ 6

If Statement - Exercises and Solution

1. Write a program to find maximum between two numbers

2. Write a program to find maximum between three numbers

3. Write a program to check whether a number is negative, positive or zero

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

5. Write a program to check whether a number is even or odd

6. Write a program to check whether a year is leap year or not

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

8. Write a program to input any alphabet and check whether it is vowel or consonant

9. Write a program to input any character and check whether it is alphabet, digit or special
character

10. Write a program to check whether a character is uppercase or lowercase alphabet

11. Write a program to input week number and print week day

12. Write a program to input month number and print month Name

13. Write a program to count total number of notes in given amount

14. Write a program to input angles of a triangle and check whether triangle is valid or not
15. Write a program to input all sides of a triangle and check whether triangle is valid or
not
16. Write a program to check whether the triangle is equilateral, isosceles or scalene
triangle

17. Write a program to find all roots of a quadratic equation

18. Write a program to calculate profit or loss

19. Write a 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

20. Write a 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%

21. Write a 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 150 units Rs. 0.75/unit
• For next 250 units Rs. 1.20/unit
• For unit above 250 Rs. 1.50/unit
• An additional surcharge of 20% is added to the bill
22. while purchasing certain items, a discount of 10% is offered if the quantity purchased is
more than 100. If quantity and price per item are input through the keyboard, write a
program to calculate the total expenses

23. The current year and the year in which the employee joined the organization are
entered through the keyboard. If the number of years for which the employee has served
the organization is greater than 3 then a bonus of Rs. 2500/- is given to the employee. If
the years of service are not greater than 3, then the program should do nothing

24. If his basic salary is less than Rs. 1500, then HRA = 10% of basic salary and DA = 90% of
basic salary. If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA =
98% of basic salary. If the employee's salary is input through the keyboard write a program
to find his gross salary

25. The marks obtained by a student in 5 different subjects are input through the
keyboard. The student gets a division as per the following rules: Write a program to
calculate the division obtained by the student
• Percentage above or equal to 60 - First division
• Percentage between 50 and 59 - Second division
• Percentage between 40 and 49 - Third division
• Percentage less than 40 – Fail

26. A company insures its drivers in the following cases:


• If the driver is married
• If the driver is unmarried, male & above 30 years of age
• If the driver is unmarried, female & above 25 years of age

27. Write a program to calculate the salary as per the following table
Year of
Gender Service Qualifications Salary

Male >= 10 Post - 15000


Graduate

>= 10 Graduate 10000

< 10 Post - 10000


Graduate

< 10 Graduate 7000

Female >= 10 Post - 12000


Graduate

>= 10 Graduate 9000

< 10 Post - 10000


Graduate

< 10 Graduate 6000

28. A five-digit number is entered through the keyboard. Write a program to obtain the
reversed number and to determine whether the original and reversed numbers are equal
or not

29. If the ages of Ram, Shyam and Ajay are input through the keyboard, write a program to
determine the youngest of the three

30. Write a program to check whether a triangle is valid or not, when the three angles of
the triangle are entered through the keyboard. A triangle is valid if the sum of all the three
angles is equal to 180 degrees

31. Find the absolute value of a number entered through the keyboard
32. Given the length and breadth of a rectangle, write a program to find whether the area
of the rectangle is greater than its perimeter. For example, the area of the rectangle with
length = 5 and breadth = 4 is greater than its perimeter

33. A certain grade of steel is graded according to the following conditions


i. Hardness must be greater than 50
ii. Carbon content must be less than 0.7
iii. Tensile strength must be greater than 5600
The grades are as follows:
• Grade is 10 if all three conditions are met
• Grade is 9 if conditions (i) and (ii) are met
• Grade is 8 if conditions (ii) and (iii) are met
• Grade is 7 if conditions (i) and (iii) are met
• Grade is 6 if only one condition is met
• Grade is 5 if none of the conditions are met
Write a program, which will require the user to give values of hardness, carbon content and
tensile strength of the steel under consideration and output the grade of the steel

34. A library charges a fine for every book returned late. For first 5 days the fine is 50
paise, for 6-10 days fine is one rupee and above 10 days fine is 5 rupees. If you return the
book after 30 days your membership will be cancelled. Write a program to accept the
number of days the member is late to return the book and display the fine or the
appropriate message

35. In a company, worker efficiency is determined on the basis of the time required for a
worker to complete a particular job. If the time taken by the worker is between 2 – 3
hours, then the worker is said to be highly efficient. If the time required by the worker is
between 3 – 4 hours, then the worker is ordered to improve speed. If the time taken is
between 4 – 5 hours, the worker is given training to improve his speed, and if the time
taken by the worker is more than 5 hours, then the worker has to leave the company. If
the time taken by the worker is input through the keyboard, find the efficiency of the
worker
36. Write a Java program that accepts three numbers and check All numbers are equal or
not

37. Write a Java program that reads an positive integer and count the number of digits

38. Write a java program that accepts three numbers from the user and check if numbers
are in "increasing" or "decreasing" order

39. Write a Java program to create a simple calculator

40. Write a Java program to check whether the given integer is a multiple of 5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy