Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

1. Write a Java program to print "Hello, World!" to the console.

2. Write a Java program that takes two integers as input from the user and prints their
sum.
3. Write a Java program that takes a number from the user and prints whether it is even
or odd.
4. Write a Java program to calculate the area of a rectangle. The program should take the
length and width as input from the user.
5. Write a Java program to find the maximum of three numbers entered by the user.
6. Write a Java program that takes a string as input from the user and prints its reverse.
7. Write a Java program to check if a given string is a palindrome or not. The program
should take the string as input from the user.
8. Write a Java program to count the number of vowels and consonants in a given string.
The program should take the string as input from the user.
9. Write a Java program to generate the Fibonacci series up to a given number n. The
program should take n as input from the user.
10. Write a Java program to find the factorial of a given number. The program should
take the number as input from the user.
11. Write a Java program to calculate the area of a circle. The program should take the
radius as input from the user.
12. Write a Java program to calculate the perimeter of a rectangle. The program should
take the length and width as input from the user.
13. Write a Java program to calculate the volume of a sphere. The program should take
the radius as input from the user.
14. Write a Java program to calculate the factorial of a given number using recursion.
15. Write a Java program to calculate the sum of digits of a given number. The program
should take the number as input from the user.
16. Write a Java program to find the GCD (Greatest Common Divisor) of two numbers
using Euclid's algorithm. The program should take the two numbers as input from the
user.
17. Write a Java program to calculate the square root of a given number using Newton's
method. The program should take the number as input from the user.

You might also like