Computer Project Soumyadeep Das

You might also like

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

NAME – SOUMYADEEP DAS

CLASS – XI SECTION– B
ROLL– 21
SUBJECT – COMPUTER APPLICATION
INTRODUCTION:
BlueJ is an integrated development environment (IDE) for the java programming
language ,developed mainly for educational purposes, but also suitable for small-
scale software development.It runs with the help of JDK (Java Development Kit).
BlueJ was developed to support the learning and teaching of object- oriented
programming and its design differs from other development environments as a
result. The main screen graphically shows the class structure of an application under
development (in a UML-like diagram), and objects can be interactively created and
tested.This interaction facility, combined with a clean, simple userinterface, allows
easy experimentation with objects underdevelopment.Object-oriented concepts
(classes, objects, communication through method calls) are represented visually and
in its interaction design in the interface.

HISTORY:
The development of BlueJ was started in 1999 by Michael Kölling and John
Rosenberg at Monash University, as a successor to the Blue[3] system. BlueJ is an IDE
(Integrated Development Environment). Blue was an integrated system with its own
programming language and environment, and was a relative of the Eiffel language.
BlueJ implements the Blue environment design for the Java programming language.

In March 2009, the BlueJ project became free and open source software, and
licensed under GPL-2.0-or-later with the Classpath exception.

Blue is currently being maintained by a team at King's College London, England,


where Kölling works.

FUNCTIONALITY:
BlueJ has a simpler interface than most professional IDEs, but its functionality is not a
subset of those kinds of environment. While many of the standard development
tools exist, such as an editor, compiler and runtime environment, it also offers tools
that are specific to its educational goals and not found in this form in common
professional environments. These includes interactive object creation and method
invocation (via the "Object Bench"), simplified debugging and teamwork controls,
interactive, line-based expression and statement evaluation (via the "Code Pad"),
and automated creation of JUnit classes from recordings of interactive test
sequences.

In this project, I took the target to complete forty programs with its necessary details
by the help of above mentioned software.

INDEX
SL NO. PROGRAM NAME PAGE NO
1
2
3
4
5
6
7
8
9
10
PROGRAM 1
BASIC MATRIX PROGRAM
Question
WAP in Java to accept a m x n matrix and print the sum of each row and column at
the end of each row and column.

Algorithm
Step 1: Start.

Step 2: Declaring class.

Step 3: Accept the number of rows and columns.


Step 4: Declare the array.

Step 5: Use for loop to accept its elements.


Step 6: Declare and initialize the variables to calculate the sums of the rows,
columns and the whole matrix.
Step 7: Use a for loop and print the elements.
Step 8: Also calculate the sum of the matrix and sum of the rows.
Step 9: After each inner loop print the row sum after the row elements.
Step 10: Also initialize the variable for the next loop.
Step 11: Use another for loop to calculate sum of the columns & print them at the
end.
Step 12: Also, initialize the variable for the next loop.
Step 13: Print the calculated sum of the whole matrix at the end.
Step 14: End.

Code
import java.util.*;
public class sumMatrix
{
public static void main (String args[])
{
Scanner sc = new Scanner (System.in);
System.out.println("Enter the number of rows and columns");
int m = sc.nextInt();
int n = sc.nextInt();
int arr[][] = new int [m][n];
System.out.println("Enter "+(m*n) +" elements for the matrix");
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
arr[i][j] = sc.nextInt();
}
}
int sum = 0, row = 0, col = 0;
System.out.print("\t\t");
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
System.out.print(arr[i][j] + " ");
sum = sum + arr[i][j];
row = row + arr[i][j];
}
System.out.print("Row Sum = " + row + "\n\t\t");
row = 0;
}
System.out.print("\nColumn sums = ");
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
col = col + arr[j][i];
}
System.out.print(col + " ");
col = 0;
}
System.out.println("\n\nThe sum of the elements of the array is "+sum);
}
}
Output

Variable Description
Sl. Data Name Purpose
no Type
1 int [ ] [ ] arr Accepting the array
2 int m Taking the number of rows
3 int n Taking the number of columns
4 int row Calculating the sum of the rows
5 int col Calculating the sum of the columns
6 int sum Calculating the sum of whole matrix
Program 2:
Sum of Diagonals

Question
WAP in Java to accept a m x n matrix and print the sum of each row and column at
the end of each row and column.

Algorithm
Step 1: Start.

Step 2: Declaring class.

Step 3: Accept the number of rows and columns.


Step 4: Declare the array.

Step 5: Use for loop to accept its elements.


Step 6: Print the whole array once using for loop.
Step 7: Declare and initialize the variables to calculate the sum of the elements of
the diagonals.
Step 8: If the element belongs to the first diagonal, add it to the variable ‘sum’.
Step 9: Print the sum of the elements of the first diagonal.
Step 10: If the element belongs to the second diagonal, add it to the variable
‘sum2’.
Step 11: Print the sum of the elements of the second diagonal.
Step 12: Start the second ‘for’ loop for the sum of the elements of the second
diagonal.
Step 13: Print the sum of the elements of the second diagonal.
Step 14: Print the sum of both the diagonals.
Step 15: End.
Code
import java.util.*;
public class diagonalSum
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of rows and columns");
int m = sc.nextInt();
int n = sc.nextInt();
int arr[][] = new int [m][n];
System.out.println("Enter "+(m * n)+" elements for the array");
for ( int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
arr[i][j] = sc.nextInt();
}
}
System.out.println("The array");
for ( int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
System.out.print(arr[i][j]+ " ");
}
System.out.println();
}
int sum = 0;
int sum2 = 0;

for ( int i = 0; i < m; i++)


{
for (int j = 0; j < n; j++)
{
if ( i == j )
{
sum = sum + arr[i][j];
}
}
}
System.out.println("The sum of the elements of the first diagonal is "+sum);
for ( int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
if ( j == (n - 1 - j))
{
sum2 = sum2 + arr[i][j];
}
}
}
System.out.println("The sum of the elements of the second diagonal is "+
sum2);
System.out.println("The sum of the elements of both the diagonals is "+(sum2
+ sum));
}
}
Output
Variable Description
Sl.no Data Name Purpose
Type
1 int [ ] [ ] arr Accepting the array
2 int m Taking the number of rows
3 int n Taking the number of columns
4 int sum Calculating the sum of the first diagonal
5 int sum2 Calculating the sum of the second diagonal
PROGRAM 3
Boundary and non boundary Elements
Question
WAP in Java to accept a m x n matrix and print the boundary and non boundary
elements in their format.

Algorithm
Step 1: Start.

Step 2: Declaring class.

Step 3: Accept the number of rows and columns.


Step 4: Declare the array.

Step 5: Use for loop to accept its elements.


Step 6: Print the whole array once using for loop.
Step 7: If the element lies in the boundary, then print the element otherwise only
print two spaces to take the place of the non boundary element.
Step 8: If the element does not lie in the boundary, then print only two spaces to
take the place of the boundary element otherwise print the element.
Step 9: End of class

Code
import java.util.*;
public class boundary
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of rows and columns");
int m = sc.nextInt();
int n = sc.nextInt();
int arr[][] = new int [m][n];
System.out.println("Enter "+(m * n)+" elements for the array");
for ( int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
arr[i][j] = sc.nextInt();
}
}
System.out.println("The array");
for ( int i = 0; i < m; i++)
{

for (int j = 0; j < n; j++)


{
System.out.print(arr[i][j]+ " ");
}
System.out.println();
}
System.out.println("The boundary elements are ");
for ( int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
if (( i == 0 ) || ( i == (n - 1)) || ( j == 0 ) || ( j == (m - 1)))
{
System.out.print(arr[i][j]+ " ");
}
else
{
System.out.print(" ");
}
}
System.out.println();
}
System.out.println("The non boundary elements are ");
for ( int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
if (( i == 0 ) || ( i == (n - 1)) || ( j == 0 ) || ( j == (m - 1)))
{
System.out.print(" ");
}
else
{
System.out.print(arr[i][j]+ " ");
}
}
System.out.println();
}
}
}
Output
Variable Description
Sl.no Data Name Purpose
Type
1 int [ ] [ ] arr Accepting the array
2 int m Taking the number of rows
3 int n Taking the number of columns
Program 4
Perfect number
Question
Write a program to enter a number and use functions to check if it’s a perfect
number or not.
Algorithm
Step 1:start
Step 2:user enters a number which is stored in variable x
Step 3:on creating the objrct the paramaterized constructer is
called and its assigns the class variable n with the number entered
by the user
Step 4:object is made and check function is called from the main
function
Step 5:from the void check function,isperfect function is called
Step 6:in the isperfect function the sum_of_factor function is
called
Step 7:in the sum_of_factor ,ther the sum of its proper divisors of
the number is stored in variable s which is returned to isperfect
function
Step 8:now the is perfect function checks that the number is
perfect or not and returns the value to check function
if
the sum of its proper divisors = the number;
return true;
else
return false;
Step 9:now to check function checks that
if
returned value =true
print "its a perfect number"
else
print "its no a perfect number"
Step 10:end

Code
import java.util.*;

public class Perfect{

int n;

Perfect(int m){

n = m;

int sum_of_factor(int a) {

int s = 0;

for ( int i = 1; i < a; i++) {

if ( a % i == 0 ){

s = s + i;

return s;

boolean isperfect() {

if (sum_of_factor(n) == n)
{

return true;

else

return false;

void check()

if ( isperfect() == true ) {

System.out.println("Its a perfect number");

else

System.out.println("Its not a perfect number");

public static void main(String args[]){

int x;

Scanner sc = new Scanner(System.in);

System.out.println("Enter the number");

x = sc.nextInt();

Perfect obj = new Perfect(x);

obj.check();
}

Output

Variable description table

Sl.no Data Name Purpose


Type
1 int n For storing the number entered by the user
2 int s For storing sum

Program 5
Disarium
Question
Write a program to check whether a number is a disarium number or not while using
the following details: -

Class name: Disarium

Data members: int num: to store the input number

Member Functions: -

Disarium (int nn): to initialize the num into nn

Int count_digit (int): to count and return the no. of digits of the given number
int sum_of_digits(int): will return the sum of the digits by power of each digit by
calling count_digit (int)

boolean check (): will check and return true if disarium else false

Implement the main function to call the method and print the appropriate message.

Algorithm
Algorithm for the constructor disarium (int m)

Step 1: Start of algorithm.

Step 2: Store the value of n in the global integer variable num

Step 3: End of algorithm.

Algorithm for the void countDigit()

Step 1: Start of algorithm.

Step 2: Declare a variable to store num to ensure value of num is not changed.

Step 3: Use while loop to find the size of the number.

Step 4: End of algorithm.

The algorithm for the method sumofdigits(int, int)

Step 1: Start of algorithm.

Step 2: Check whether number is less than 10. If so, return the value of that number
raised to single power. In other words, if the number is single digit, then raise it to the
power 1.

If not, then the last digit of the number is being raised to power 1 and the rest is being
sent to the same function by recursion so that the rest is treated as a number and the
same process is followed.

Step 3: End of algorithm.


The algorithm for the method void check()

Step 1: Start of algorithm

Step 2: Checks if the entered number and the number returned by the sum of digits
function is same or not.

If they are same its printing : “The number is a disarium number.”

Otherwise its printing : “The number is a disarium number.”

Step 3: End of algorithm

Algorithm for main function

Step 1: Start of algorithm.

Step 2: Accept the number in n

Step 3: Creating object ob.

Step 4: Calling the functions countDigit and check

Step 5: End of algorithm

Code
import java.util.*;

public class disarium

int num,size;

disarium(int n)

num=n;

size=0;

}
void countDigit()

int i=num;

while (i!=0)

int d= i%10;

size++;

i=i/10;

int sumofdigits(int n,int p)

if(n<10)

return((int)Math.pow(n,p));

else

int t=((int)Math.pow(n%10,p));

return(t+sumofdigits(n/10,--p));

void check()

if(num==sumofdigits(num,size))
{

System.out.println(num+" is a disarium number.");

else{

System.out.println(num+" is not a disarium number");

public static void main(String args[])

Scanner sc=new Scanner(System.in);

System.out.println("Enter the number.");

int m=sc.nextInt();

disarium ob = new disarium(m);

ob.countDigit();

ob.check();

Output
PROGRAM 6
Bubble sort
Question
WAP in Java to accept a m x n matrix and sort all the elements of the array using
bubble sort technique.

Algorithm
Step 1: Start.

Step 2: Declaring class.

Step 3: Accept the number of rows and columns.


Step 4: Declare the array.

Step 5: Use for loop to accept its elements.


Step 6: Print the whole array once using for loop.
Step 7: Declared a second (but one dimensional) array and take the elements of the
first array into the second array for sorting using one for loop.
Step 8: Declare the

Step 8: Sorted the second array using bubble sort technique.


Step 9: Inserted the elements into the main array after sorting using for loop.
Step 10: Printed the final sorted array.

Step 11: End.

Code
import java.util.*;
public class bubbleSORT
{
public static void main(String args[])
{
Scanner sc = new Scanner (System.in);
System.out.println("Enter the number of rows and columns");
int m = sc.nextInt();
int n = sc.nextInt();
int arr[][] = new int [m][n];
System.out.println("Enter the elements for the array");
for ( int i = 0; i < m; i++)
{
for ( int j = 0; j < n; j++)
{
arr[i][j] = sc.nextInt();
}
}
System.out.println("The unsorted array");
for ( int i = 0; i < m; i++)
{
for ( int j = 0; j < n; j++)
{
System.out.print(arr[i][j] + " ");
}
System.out.println();
}

int a[] = new int [m * n];


int k = 0;
for ( int i = 0; i < m; i++)
{
for ( int j = 0; j < n; j++)
{
a[k] = arr[i][j];
k++;
}
}
int t = 0;
for ( int i = 0; i < a.length - 1; i++)
{
for ( int j = 0; j < a.length - i - 1; j++)
{
if ( a[j] > a[j + 1])
{
t = a[j];
a[j] = a[j + 1];
a[j + 1] = t;
}
}
}
k = 0;
for ( int i = 0; i < m; i++)
{
for ( int j = 0; j < n; j++)
{
arr[i][j] = a[k];
k++;
}
}
System.out.println("The sorted array :");
for ( int i = 0; i < m; i++)
{
for ( int j = 0; j < n; j++)
{
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}
Output

Variable Description
Sl.no Data Name Purpose
Type
1 int [ ] [ ] arr Accepting the array
2 int m Taking the number of rows
3 int n Taking the number of columns
4 int [ ] a Taking the elements for sorting
5 int temp Temporary variable for sorting
6 int k Index variable for second array
PROGRAM 7
Column sort
Question
WAP in Java to accept a m x n matrix and sort all the columns of the array using bubble sort
technique.

Algorithm

Step 1: Start.

Step 2: Declaring class.

Step 3: Accept the number of rows and columns.

Step 4: Declare the array.

Step 5: Use for loop to accept its elements.

Step 6: Print the whole array once using for loop.

Step 5: Sort the rows using the same bubble sort technique but just add another loop
outside the two loops which ensures that only the rows are trans versed and sorted.

Step 6: Print the final array.

Step 7: End of class.

Code

import java.util.*;

public class ColSort

{
public static void main(String args[])

Scanner sc = new Scanner (System.in);

System.out.println("Enter the number of rows and columns");

int m = sc.nextInt();

int n = sc.nextInt();

int arr[][] = new int [m][n];

System.out.println("Enter the elements for the array");

for ( int i = 0; i < m; i++)

for ( int j = 0; j < n; j++)

arr[i][j] = sc.nextInt();

System.out.println("The unsorted array");

for ( int i = 0; i < m; i++)

for ( int j = 0; j < n; j++)


{

System.out.print(arr[i][j] + " ");

System.out.println();

int a[] = new int [m];

int temp = 0;

for( int i = 0; i < m; i++)

for ( int j = 0; j < n - 1; j++)

for ( int k = 0; k < n - j - 1; k++)

if ( arr[k][i] > arr[k + 1][i])

temp = arr[k][i];

arr[k][i] = arr[k + 1][i];

arr[k + 1][i] = temp;

}
}

System.out.println("The sorted array");

for ( int i = 0; i < m; i++)

for ( int j = 0; j < n; j++)

System.out.print(arr[i][j] + " ");

System.out.println();

}
Output
PROGRAM 8
Row sort
Question
WAP in Java to accept a m x n matrix and sort all the rows of the array usingbubble sort
technique.
Algorithm
Step 1: Start.

Step 2: Declaring class.

Step 3: Accept the number of rows and columns.


Step 4: Declare the array.

Step 5: Use for loop to accept its elements.


Step 6: Print the whole array once using for loop.
Step 5: Sort the rows using the same bubble sort technique but just add anither loop outside
the two loops which ensures that only the rows are transversed andsorted.
Step 6: Print the final array.

Step 7: End of class.

Code
import java.util.*; public class
RowSort
{
public static void main(String args[])
{
Scanner sc = new Scanner (System.in); System.out.println("Enter the
number of rows and columns");
int m = sc.nextInt(); int n =
sc.nextInt();
int arr[][] = new int [m][n];
System.out.println("Enter the elements for the array"); for ( int i =
0; i < m; i++)
{
for ( int j = 0; j < n; j++)
{
arr[i][j] = sc.nextInt();
}
}
System.out.println("The unsorted array"); for ( int i
= 0; i < m; i++)
{
for ( int j = 0; j < n; j++)
{
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
int temp = 0;
for( int i = 0; i < m; i++)
{
for ( int j = 0; j < m - 1; j++)
{
for ( int k = 0; k < m - j - 1; k++)
{
if ( arr[i][k] > arr[i][k + 1])
{
temp = arr[i][k]; arr[i][k] =
arr[i][k + 1];arr[i][k + 1] = temp;
}
}
}
}
System.out.println("The sorted array"); for ( int i
= 0; i < m; i++)
{
for ( int j = 0; j < n; j++)
{
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}

Output

Variable Description
Sl.no Data Name Purpose
Type
1 int [ ] [ ] arr Accepting the array
2 int m Taking the number of rows
3 int n Taking the number of columns
4 int temp Temporary variable for sorting
5 int k Extra loop variable
PROGRAM 9
Magic number
Question
Write a program to check whether a number is a magic number or not while using the following
details: -

Class name: Magic

Data members: int n : to store the input number

Member Functions: -

Magic (int nn): to initialize the n into nn

int sum_of_digits (int): will return the sum of the digits

boolean check (): will check and return true if magic else false by calling sum_of_digits(int)
function

Implement the main function, call the above methods, and print appropriately the message.

Algorithm
Step 1:start

Step 2:a number is entered by a user and stored in variable x

Step 3:object is made and paramaterized constructer is called

Step 4:in the constructer the class variable n is assinged with the value the user entered

Step 5:check function is called

Step 6:from it sum_of_digits function is called and the number is passed

Step 7:in the sum_of_digits function the sum of the digits of the number is calculated and
returned to check function;

Step 8:now after certain calculation it will check the magic number

if sum == 1
return true;

else

return false;

Step 9:now in the main function

if ( y == true )

print "The entered number is magic number"

else

print "The entered number is not a magic number"

Step 10:end

Code
import java.util.*;

public class Magic{

int n;

static Scanner sc = new Scanner(System.in);

Magic ( int nn )

n = nn;

int sum_of_digits(int a)

int sum = 0;

int aa = a;

while ( aa != 0 )
{

sum = sum + ( aa % 10 );

aa = aa / 10;

return sum;

boolean check()

int b = n;

int sum = 0;

sum = n;

while( sum > 9 )

b = sum;

sum = 0;

sum = sum_of_digits(b);

if ( sum == 1 )

return true;

else

return false;

}
}

public static void main (String args[])

int x;

System.out.println("Enter the number");

x = sc.nextInt();

Magic obj = new Magic(x);

boolean y =false;

y = obj.check();

if ( y == true )

System.out.println("The entered number is magic number");

else

System.out.println("The entered number is not a magic number");

Output
Variable Description
Sl.no Data Name Purpose
Type
1 int nn Accepting the no entered by the user
2 int sum For storing the sum
3 boolean y Checking the no is magic or not

PROGRAM 10
Word wise
Question
Design a class WordWise to separate words from a sentence and find the
frequency of the vowels in each word. Some of the members of the class
are given below:
Class name: WordWise
Data members/instance variables:
str: to store a sentence
freq : to store the frequency of vowels
Member functions/methods:
WordWise( ) : default constructor
void readsent( ) : to accept a sentence
int freq_vowel(String w): returns the frequency of vowels in the
parameterized string w
void arrange (): displays each word of the sentence in a separate line along
with the frequency of vowels for each word by invoking the function
freq_vowel( )
Define the class WordWise giving details of the constructor (), void
readsent(), int freq_vowel(String) and void arrange (). Define the main ()
function to create an object and call the functions accordingly to enable
the task.
Algorithm
Step 1:start

Step 2:object is created and constructed is called(where str is initialized)

Step 3:readsent and arrange functions are called

Step 4:in readsent function the string is taken input

Step 5:in arrange function, a extra space is added to the string first

then a for loop is runed to calculate to get the desired output but to do that freq_vowel is
called

Step 6: using the freq_vowel function the frequency of vowel in a word is calculated

Step 7:then in the arrange function

if

no space is encountered then the character that is being extracted will accumulate int the
word variable

but if

space is encounter then it prints the desired output in acertain format

Step 8:end
Code
import java.util.*;

public class WordWise

{
String str;

WordWise()
{
str="";
}

void readsent()
{
Scanner in = new Scanner(System.in);
System.out.println("enter a string");

str=in.nextLine();
}
int freq_vowel(String w)
{
int c = 0;
for(int i=0;i<w.length();i++)
{

char ch = w.charAt(i);
char ch1 = Character.toUpperCase(ch);
if(ch1=='A' || ch1=='E' || ch1=='I' || ch1=='O' || ch1=='U')
{

c++;
}
}
return c;
}
void arrange()
{
WordWise obj = new WordWise();
for(int i=0;i<s.length();i++)
{
if(s.charAt(i)==' ')
{
int Vcount = obj.freq_vowel(word);
System.out.println(word + " " + Vcount);
word="";
}

else

word=word+s.charAt(i);

}
}
}
public static void main(String args[])
{
WordWise obj = new WordWise();

obj.readsent();
obj.arrange();
}
}
Output

Variable Description
Sl.no Data Name Purpose
Type
1 string str to store a sentence
2 int freq to store the frequency of vowels

3 char ch To store character while character extration


PROGRAM 11
Special number
Question
Special number is also known as Krishnamurthy number and Strong number. A special number
is a number in which the sum of the factorial of each digit is equal to the number itself.

For example: 145.

1!+4!+5!= 1+24+ 120 145.

Thus, 145 is a special number.

Design a class Special to check if a given number is a special number. Some of the members of
the class are given below:

Class name: Special

Data members:

n: to store the integer. Member functions:

Special: constructor to assign 0 to n.

Special (int): parameterized constructor to assign a value to 'n'.

void sum(): calculate and display the sum of the first and last digit of 'n'. void isSpecial(): check
and display if the number 'n' is a special number.

Specify the class Special giving details of the constructors, void sum and void isSpecial().

Algorithm
Algorithm for main function:

Step 1: Start of Algorithm for the main method.

Step 2: A scanner object is created.

Step 3: The function display() is called.


Step 4:End of algorithm of main method.

Algorithm for void display0:

Step 1: Storing the number entered by the user in the integer type variable "n"..

Step 2: The function isSpecial(n) is called by passing "n" as a formal parameter.

Step 3: End of algorithm.

Algorithm for void isSpecial(int n):

Step 1: Assuming the "s" integer type variable to be 0 and declaring the "d: variable as integer
type variable.

Step 2: Assuming the "copy" integer type variable to be "n".

Step 3: Starting the while loop and the condition is (n>0)

d= n%10;

s=s+factorial(d);

n=n/10.

Step 4: Check the condition (s==copy)

If true

Print - It is a special number.

If false

Print - It is not a special number.

Step 5: End of algorithm.

Algorithm for int factorial(int n):

Step 1: Check the condition (n==0)

If true

Return 1;
Else

Return the value of ((n*factorial(n-1))).

Step 2: End of the algorithm.

Code
import java.util.*;

public class Special

static Scanner sc=new Scanner (System.in);

int factorial (int n)

if (n==0)

return 1;

else

return (n*factorial (n-1));

void isSpecial (int n) {

int d,s=0, copy=n;

while (n>0)

d=n%10;
s=s+factorial (d);

n=n/10;

if (s==copy)

System.out.println("It is a Special Number.");

else

System.out.println("It is not a Special Number.");

void display ()

System.out.println("Enter any Number: ");

int n=sc.nextInt();

isSpecial(n);

public static void main (String args[])

Special ob=new Special ();

ob.display();

}
Output

Variable Description
CONCLUSION:
After completing the project, I found out that this software has many features which are advantageousto
beginners.

Some of the features of Blue) are:

The tasks can be performed more conveniently.

It shows you a sample program to give a give a brief idea ofprogramming.

Debugging is easy as it indicates errors at bottom of screen.

It is a simpler interface than any other IDE.

It has some new features which are not seen in any other IDE.

Bluej can run run on Windows, MacOS, Linux or anyplatforms which runs java.

It allows you to interact with objects.

ACKNOWLEDGEMENT
I would like to earnestly acknowledge the sincere efforts and valuable time given by my
respected teachers - Payel maam and kaustav Sir. I would also like to express my special
thanks of gratitude to our respected Principal - Mrs. Kakoli Ghosh, who gave me the golden
opportunity to do this wonderful project, which also helped me in doing a lot of Research and I
came to know about so many new ways of implementing logic in the programs. Their valuable
guidance, innovative ideas and feedback has helped me in completing this project.

Also I would like to thank my family for their support. Without that support I couldn't have
succeeded in completing this project.

At last but not in least, I would like to thank everyone who helped and motivated me to work
on this project.

You might also like