0% found this document useful (0 votes)
1 views3 pages

Java Basics

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)
1 views3 pages

Java Basics

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

1.

Basic Programs

Write a program to input a number and display its square and cube.

Write a program to input the length and breadth of a rectangle and find its area and
perimeter.

Write a program to input temperature in Celsius and convert it into Fahrenheit.

Write a program to input the radius of a circle and calculate its area and circumference.

Write a program to input two numbers and display their sum, difference, product, and
quotient.

Write a program to swap two numbers using a third variable.

Write a program to swap two numbers without using a third variable.

Write a program to calculate simple interest.

Write a program to calculate the average of three numbers.

Write a program to input a three-digit number and display the sum of its digits.

2. Programs Using Relational Operators

Write a program to input two numbers and display the greater number.

Write a program to input a number and check whether it is positive or negative.

Write a program to input a number and check whether it is divisible by 5.

Write a program to input a number and check whether it is divisible by both 3 and 7.

Write a program to input two numbers and check whether they are equal.

3. Simple If Programs

Write a program to input a number and display "Even" if it is even.

Write a program to input a person's age and check whether he/she is eligible to vote.

Write a program to input marks and display "Pass" if marks are 40 or above.

Write a program to input salary and calculate bonus of 10% if salary exceeds ₹50,000.

Write a program to input a character and check whether it is an uppercase letter.

4. If-Else Programs

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


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

Write a program to find the larger of two numbers.

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

Write a program to check whether a character is a vowel or consonant.

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

Write a program to find the absolute value of a number.

Write a program to input a student's marks and display Pass or Fail.

Write a program to check whether a person is eligible for a driving license (age ≥ 18).

Write a program to find the smaller of two numbers.

5. Nested If / Multiple If-Else Programs

Write a program to find the largest among three numbers.

Write a program to find the second largest among three numbers.

Write a program to classify a person as Child, Teenager, Adult, or Senior Citizen based on
age.

Write a program to calculate electricity bill:

First 100 units: ₹2/unit

Next 200 units: ₹3/unit

Above 300 units: ₹5/unit

Write a program to assign grades:

A : 90 and above

B : 75–89

C : 60–74

D : 40–59

F : Below 40

Write a program to determine whether a triangle is Equilateral, Isosceles, or Scalene.

Write a program to find the largest among four numbers.


Write a program to input three angles and check whether they form a valid triangle.

Write a program to check whether a character is an alphabet, digit, or special character.

You might also like