Professional Documents
Culture Documents
Page 1 of 18
opasdfghjklzxcvbnmqwertyuiopasdfgh
jklzxcvbnmqwertyuiopasdfghjklzxcvb
nmqwertyuiopasdfghjklzxcvbnmqwer
COMPUTER
tyuiopasdfghjklzxcvbnmqwertyuiopas
PROJECT
dfghjklzxcvbnmqwertyuiopasdfghjklzx
cvbnmqwertyuiopasdfghjklzxcvbnmq
FILE
wertyuiopasdfghjklzxcvbnmqwertyuio
pasdfghjklzxcvbnmqwertyuiopasdfghj
<Name>
klzxcvbnmqwertyuiopasdfghjklzxcvbn
<Class>
mqwertyuiopasdfghjklzxcvbnmqwerty
<Roll Number>
uiopasdfghjklzxcvbnmqwertyuiopasdf
ghjklzxcvbnmqwertyuiopasdfghjklzxc
vbnmqwertyuiopasdfghjklzxcvbnmrty
uiopasdfghjklzxcvbnmqwertyuiopasdf
ghjklzxcvbnmqwertyuiopasdfghjklzxc
Page 2 of 18
Personal
Memo
Name:
Class:
Roll no.:
Subject:
Subject Teacher:
Guardian Teacher:
Page 3 of 18
Acknowledge
ment
“One’s put to work and one’s put a guide because a voyage is aimless
without a key and education is incomplete without a guide.”
<Name>
<Class>
Contents
Serial Program Page No. Sign Remarks
No.
1. Fantastic Number 5
2. String Fibonacci 8
3. Happy Number 12
4. Sorting/Searching 17
5. ISBN Number 24
6. Sum of Numbers 28
7. Transpose of Array 31
8. Date Based Program 35
9. Palindromic words 38
10. Vowels & 42
Consonants
11. File Creation 46
12. Logic Based Program 49
13. Unit Matrix 52
14. Object Passing 56
Page 5 of 18
15. Stack 59
16. Recursion 64
17. Currency Denomination 67
18. Inheritance 70
19. Linked List 75
20. Sequential Series 78
21. Prime Pattern 82
22. Recursion in Array 85
23. String Based 88
24. Phone Numbers 91
25. Primorial Number 94
PROGRAM 1
Write a program in java to print all three-digit fantastic numbers. A fantastic number is a
number which when multiplied three times and the numbers thus formed result in
formation of a new number as shown below. This number has no repetition of digits and
all digits from one to nine occur (in any sequence).
Example:
327*1= 327
327*2=654
327*3=981
n=327654981
(Here in the number n there is no repetition of digits and all digits from 1 to 9 are
present)
ALGORITHM
Step 1: Start
Step 4: p:=j*I;
Step 7: if(num.indexOf(c)<0)
PROGRAM CODE
{
Page 7 of 18
String num="";
p=j*i;
num=num+p;
if(num.indexOf(c)<0)
f=1;
if(num.length()==9&&f==0)
VARIABLE DESCRIPTION
OUTPUT
Page 8 of 18
Page 9 of 18
PROGRAM 2
S0=”a”, S1=”b”, Sn=S(n-1)+S(n-2) where ‘+’ denotes concatenation. Thus the sequence
is : a, b, ba, bab, babba, babbabab, …………n terms.
Design a class FiboString to generate fibonnaci strings. Some of the members of the
class are given below:
Specify the class FiboString, giving details of the constructor(), void accept(), and
void generate(). Define the main() function to create an object and call the functions
accordingly to enable the task.
Page 10 of 18
ALGORITHM
Step1: Start
int n
constructor FiboString()
Step 3: x:=“a”
Step 4: y:=“b”
Step 5: z:=“ba”
void accept()
Step 6: Create an object (say ob) to input data from the user
void generate()
void main()
Step 16: Create the object of the class (say obj) of FiboString
PROGRAM CODE
import java.io.*;
String x,y,z;
int n;
public FiboString()
x="a";
y="b";
z="ba";
n=Integer.parseInt(ob.readLine());
void generate()
int i;
{
Page 12 of 18
z=y+x;
x=y;
y=z;
System.out.print(z+" ");
obj.accept();
obj.generate();
VARIABLE DESCRIPTION
OUTPUT
Page 13 of 18
PROGRAM 3
= 4 + 64 = 68
68 = (6)2+ (8)2
= 36 + 64 = 100
100 = (1)2+(0)2+(0)2
= 1+0+0 = 1
Example: 12 = (1)2+(2)2
= 1+ 4 = 5
Design functions as per your requirement and use recursive technique in at least
one of the function designed by you. Also define main() function to create an object
and call the methods to check for happy number.
ALGORITHM
Step 1: Start
Step 3: Create an object (say ob) to input data from the user
Constructor Happy()
getnum(int nn)
Step 6: if(x>0)
Page 14 of 18
Step 8: s:=s+d*d
Step 9: x:=x/10
return s
void ishappy()
void main()
Step 29: Get input from the user (say in variable num)
PROGRAM CODE
import java.io.*;
int n, s, d;
Happy()
n=0;
n=nn;
int sum_sq_digits(int x)
if(x>0)
d=x%10;
s=s+d*d;
x=x/10;
return(sum_sq_digits(x));
else
Page 16 of 18
return s;
void ishappy()
int a;
while(n>9)
s=0;
n=sum_sq_digits(n);
if(n==1)
System.out.println("HAPPY NUMBER");
else
int num;
System.out.println("ENTER A NUMBER");
num=Integer.parseInt(ob.readLine());
obj.getnum(num);
obj.ishappy();
VARIABLE DESCRIPTION
OUTPUT
Page 18 of 18