Java With BlueJ 12 BOARD PROJECTT
Java With BlueJ 12 BOARD PROJECTT
With
BlueJ
INDEX
Question 1
Design a class PrimePalinGen to generate prime palindrome numbers.
[A number is said to be prime palindrome of the number is a prime as well as
palindrome number]
[Prime number : A number which is divisible by 1 and itself.]
[Palindrome number : A number which is same as its reverse]
Example: 11 (where 11 is a prime number and a palindrome number) Some of the
members of the class are given below:
Class name : PrimePalinGen
Data members/instance variables:
start : to store the start of range
end : to store the end of range
Methods/member functions:
PrimePalinGen(int a, int b) : parametrized constructor to inilialise the
data members.
int isPrime(int i) : returns 1 if the number is prime otherwise
return 0. int isPalin(int i) : returns 1 if the number is prime otherwise return 0.
void generate() : generates all prime palindrome numbers
between start and end by invoking the functions isPrime() and isPalin().
Specify the class PrimePalinGen giving details of the constructor(), int
isPrime(int), int isPalin(int) and void generate(). Define a main() function to create
an object and call the functions accordingly to enable the task.
Solution:
mport java.util.*;
PrimePalinGen(int a, int b)
{
start = a;
end = b;
}
Algorithm:
1. Define a class PrimePalinGen with instance variables start and end.
2. Implement a parameterized constructor to initialize start and end.
3. Implement methods isPrime and isPalin to check if a number is prime and
palindrome, respectively.
4. Define a method generate to generate all prime palindrome numbers between start and
end.
5. In the main function, create an object of the class PrimePalinGen, take input for range
from the user, and call the generate method.
Question 2
A Prime-Adam integer is a positive integer (without leading zeros) which is a prirne as well
as an Adam number.
Prime number : A number which has only two factors, i.e. 1 and the number itself.
Example: 2, 3, 5, 7 …etc.
Adam number: The square of a number and the square of its reverse are reverse to each other.
Exarnple: If n=13 and reverse of ‘n’ =31, then,
(13)2 = 169
(31)2 = 961 which is reverse of 169 thus 13, is an Adam number.
Accept two positive integers m and n, where m is less than n as user input. Display all Prime-
Adam integers that are in the range between m and n (both inclusive) and output them along
with the frequency, in the format given below:
Solution:
import java.util.Scanner;
int count = 0;
Variable Description: