This repository contains 15 simple Java problems designed to help beginners build logic and improve their programming skills.
Problem: Write a Java program that prints "Hello, World!"
to the console.
Problem: Write a Java program that takes two numbers as input and prints their sum.
Example:
Input: 5, 10
Output: 15
Problem: Write a Java program to check whether a number is even or odd.
Example:
Input: 7
Output: Odd
Problem: Write a Java program to find the largest number among three given numbers.
Example:
Input: 5, 12, 7
Output: 12
Problem: Write a Java program to print numbers from 1 to 10 using a loop.
Output:
1 2 3 4 5 6 7 8 9 10
Problem: Write a Java program to find the factorial of a number.
Example:
Input: 5
Output: 120
(Factorial of 5 = 5 × 4 × 3 × 2 × 1 = 120)
Problem: Write a Java program to reverse a given number.
Example:
Input: 1234
Output: 4321
Problem: Write a Java program to check whether a number is prime or not.
Example:
Input: 7
Output: Prime
Problem: Write a Java program to print the multiplication table of a given number.
Example:
Input: 5
Output:
5 x 1 = 5
5 x 2 = 10
...
5 x 10 = 50
Problem: Write a Java program to check whether a number is a palindrome.
Example:
Input: 121
Output: Palindrome
(A palindrome is a number that reads the same backward as forward.)
Problem: Write a Java program to count the number of digits in a given number.
Example:
Input: 12345
Output: 5
Problem: Write a Java program to find the sum of digits of a given number.
Example:
Input: 123
Output: 6
(Sum = 1 + 2 + 3 = 6)
Problem: Write a Java program to swap two numbers without using a third variable.
Example:
Input: a = 5, b = 10
Output: a = 10, b = 5
Problem: Write a Java program to print the Fibonacci series up to n
terms.
Example:
Input: 7
Output: 0 1 1 2 3 5 8
(Fibonacci series: Each number is the sum of the two preceding ones.)
Problem: Write a Java program to calculate the power of a number using a loop.
Example:
Input: 2^3
Output: 8
Note : Do not use Chat gpt and other AI tools to solve and complete the task no. 1