Module 2: Conditional Programs

Java programs that use if-else, nested if, and switch-case to make decisions based on conditions.

20 program solutions

Back to Topics

Program Solutions

1

Grade Calculator

Calculate grade based on percentage using conditional statements.

Beginner
View Solution
2

Vowel or Consonant

Check whether a character is a vowel or a consonant.

Beginner
View Solution
3

Check Alphabet/Digit/Special Character

Check whether a character is an alphabet, digit, or special character.

Beginner
View Solution
4

Check Leap Year

Check whether a given year is a leap year.

Beginner
View Solution
5

Check Armstrong Number

Check whether a number is an Armstrong number (sum of digits^number-of-digits equals the number).

Intermediate
View Solution
6

Check Perfect Number

Check whether a number is a perfect number (sum of proper divisors equals the number).

Intermediate
View Solution
7

Check Strong Number

Check whether a number is a strong number (sum of factorials of digits equals the number).

Intermediate
View Solution
8

Check Palindrome Number

Check whether a number is a palindrome (same forwards and backwards).

Beginner
View Solution
9

Max of 3 Using Nested If

Find the maximum of three numbers using nested if statements.

Beginner
View Solution
10

Electricity Bill Calculator

Calculate electricity bill based on units consumed using slab rates.

Intermediate
View Solution
11

Menu-Driven Calculator

Implement a simple calculator using switch-case based on user choice.

Beginner
View Solution
12

Profit or Loss

Determine profit or loss based on cost price and selling price.

Beginner
View Solution
13

Triangle Validity Check

Check if three sides can form a valid triangle using triangle inequality.

Beginner
View Solution
14

Roots of Quadratic Equation

Find the roots of a quadratic equation ax^2 + bx + c = 0 using discriminant.

Intermediate
View Solution
15

Person Eligibility (Age Check)

Check if a person is eligible to vote based on age.

Beginner
View Solution
16

Library Fine Calculation

Calculate library fine based on number of days a book is overdue.

Intermediate
View Solution
17

Attendance Percentage Calculator

Calculate attendance percentage and decide if a student is allowed to sit in exam.

Beginner
View Solution
18

Temperature Classification

Classify temperature as cold, moderate, or hot using conditions.

Beginner
View Solution
19

Discount Calculator

Apply discount based on purchase amount using conditional logic.

Beginner
View Solution
20

Basic Authentication Program

Check username and password against hardcoded values.

Beginner
View Solution