0% found this document useful (0 votes)
2 views7 pages

Java Tasks

The document outlines a series of Java practice tasks over seven days, each consisting of two programming problems. Tasks include extracting prime digits, generating Fibonacci series, calculating factorials, reversing numbers, identifying largest digits, counting even and odd digits, and checking for strong and Armstrong numbers. Each task includes a problem statement, sample input, and expected output.

Uploaded by

hihi.32143214
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Java Tasks

The document outlines a series of Java practice tasks over seven days, each consisting of two programming problems. Tasks include extracting prime digits, generating Fibonacci series, calculating factorials, reversing numbers, identifying largest digits, counting even and odd digits, and checking for strong and Armstrong numbers. Each task includes a problem statement, sample input, and expected output.

Uploaded by

hihi.32143214
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Day 1: Java Practice Tasks

Question 1: Prime Digits in a Number

Problem Statement:

Write a Java program to extract and print only the prime digits from a given number.

Sample Input:

Enter a number: 984567

Sample Output:

Prime digits: 5, 7

Question 2: Fibonacci Series

Problem Statement:

Write a Java program to print the Fibonacci series up to the first 10 numbers.

The Fibonacci sequence starts from 0 and 1, and each number is the sum of the previous
two.

Sample Output:

Fibonacci series up to 10 numbers:

0 1 1 2 3 5 8 13 21 34
Day 2: Java Practice Tasks

Question 1: Factorial of a Number

Problem Statement:

Write a Java program to calculate the factorial of a given number.

*Factorial of n is the product of all positive integers less than or equal to n.*

Sample Input:

Enter a number: 5

Sample Output:

Factorial of 5 is: 120

Question 2: Reverse a Number

Problem Statement:

Write a Java program to reverse the digits of a given number.

Sample Input:

Enter a number: 12345

Sample Output:

Reversed number: 54321


Day 3: Java Practice Tasks:

Question 1: Find the Largest Digit in a Number

Problem Statement:

Write a Java program to find the largest digit in a given number.

Sample Input:

Enter a number: 5729

Sample Output:

Largest digit: 9

Question 2: Count Even and Odd Digits

Problem Statement:

Write a Java program that takes an integer and counts how many even and odd digits it has.

Sample Input:

Enter a number: 123456

Sample Output:

Even digits: 3

Odd digits: 3
Day 4: Java Practice Tasks

Question 1: Print Non-Fibonacci Numbers

Problem Statement:

Write a Java program to print the first n non-Fibonacci numbers.

A non-Fibonacci number is a positive integer that is not a Fibonacci number.

Sample Input:

Enter the count: 20

Sample Output:

4, 6, 7, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20

Question 2: Find Twin Prime Numbers in a Range

Problem Statement:

Write a Java program to find and display twin prime pairs in a given range.

Twin Primes are pairs of prime numbers that differ by 2 (e.g., 3 and 5, 11 and 13, etc.)

Sample Input:

Enter start: 1

Enter end: 30

Sample Output:

(3, 5)

(5, 7)

(11, 13)

(17, 19)

(29, 31)
Day 5: Java Practice Tasks

Question 1: Find Numbers with Sum of Digits Prime

Problem Statement:

Write a Java program to find and print all numbers between 2 and n such that the sum of
their digits is a prime number.

Example:

Number = 23 → 2 + 3 = 5 → 5 is prime → 23 is valid.

Sample Input:

Enter n: 50

Sample Output:

2, 3, 5, 7, 11, 12, 14, 16, 20, 21, 23, 25, 30, 32, 34, 41, 43, 50

Question 2: Find Numbers Having at Least One Even Digit

Problem Statement:

Write a Java program to find and display all numbers between two numbers that have at
least one even digit.

Example: 123 → digits are 1, 2, 3 → 2 is even → valid.

Example: 579 → digits are 5, 7, 9 → no even digits → not valid.

Sample Input:

Enter start: 20

Enter end: 35

Sample Output:

20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 34
Day 6: Java Practice Tasks

Question 1: Check if a Number is a Strong Number

Problem Statement:

Write a Java program to accept one number from the user and check whether it is a Strong
number or not.

A Strong number is a number where the sum of the factorial of each digit equals the number
itself.

Example:

145 → 1! + 4! + 5! = 1 + 24 + 120 = 145 → 145 is a Strong number.

Sample Input:

Enter number: 145

Sample Output:

145 is a Strong number.

Question 2: Check if a Number is an Armstrong Number

Problem Statement:

Write a Java program to accept one number from the user and check whether it is an

An Armstrong number of n digits is a number that is equal to the sum of its digits each raised
to the power n.

Example:

153 → 1³ + 5³ + 3³ = 153

370 → 3³ + 7³ + 0³ = 370

Sample Input:

Enter n: 153

Sample Output:

153 is an Armstrong number


Day 7: Java Practice Tasks

Question 1: Print Non-Prime Numbers from 1 to N

Problem Statement:

Write a Java program to accept a number from the user and print all non-prime numbers
between 1 and N.

Explanation:

A non-prime number is a number greater than 1 that has more than two divisors, or is
simply not a prime number.

Note: 1 is also considered non-prime.

Sample Input:

Enter number: 10

Sample Output:

Non-prime numbers between 1 and 10: 1 4 6 8 9 10

Question 2: Check if a Number is a Sunny Number

Problem Statement:

Write a Java program to check if a number is a Sunny Number.

Explanation:

A number N is called a Sunny number if N + 1 is a perfect square.

For example:

8 → 8 + 1 = 9 → √9 = 3 → Sunny number

10 → 10 + 1 = 11 → not a perfect square → Not Sunny

Sample Input:

Enter number: 8

Sample Output:

8 is a Sunny number.

You might also like