Rudra Program
Rudra Program
PURBA BARDHAMAN
[First Page]
PREFACE
Computer seems very interesting to me especially the program part .I have
always wanted to learn programming and this subject in m school have made it
possible . In my further project I have done twenty five program as directed by my
school.I have also provided the variable description along with the input and
output screen .By doing this project I have also learnt the lesson of consistency
and creativity .
ACKNOWLEDGEMENT
I would like to express my sincere gratitude to all those who have contributed in
the completion this project on time. First and foremost, I am deeply thankful to my
computer teacher , Mr Subrata Sir for his invaluable guidance,expertise and
unwavering encouragement throughout the process. Their insightful feedback and
thought provoking questions have been instrumental in shaping the direction and
quality of this work .
Finally ,I extend my appreciation to the various sources ,both online and offline
,that have been invaluable in my research and realization of this project. I am
thankful for the wealth of knowledge and expertise that the resources have made
accessible to me .
1. Write a program to input name and basic salary of an employee. Calculate and display the
gross salary and net salary when:
da= 30% of basic
hra= 12.5% of basic
pf= 10 % of basic
gross= basic + da +hra
net pay= gross – pf
PROGRAM
class prg1
}
VARIABLE DESCRIPTION FOR QUESTION 1
INPUT SCREEN
OUTPUT SCREEN
2. A certain amount is invested at the rate 10% per annum for 3 years. Find the difference
between Compound Interest (CI) and Simple Interest (SI). Write a program to take amount as
an input.
SI= (P*R*T)/100 A=P*(1+R/100)T CI= A-P
PROGRAM
class prg2
double r =10.00,t=3.00;
double A = amt*ha*ha*ha;
double ci = A-amt;
}
VARIABLE DESCRIPTION FOR QUESTION 2
INPUT SCREEN
OUTPUT SCREEN
3. The final velocity of a vehicle can be calculated by using the formula:
v2 = u2 + 2as
Where u= initial velocity, a= acceleration, s=distance covered
Write a program to calculate and display the final velocity by taking initial velocity, acceleration
and the distance covered as inputs.
PROGRAM
class pg3
double v=Math.sqrt(vsq);
VARIABLE DESCRIPTION
OUTPUT SCREEN
4. Write a program to input three unequal numbers and display the second smallest
number.
Sample Input: 65, 41, 98
Sample Output: 65
PROGRAM
class prg4
else
INPUT SCREEN
OUTPUT SCREEN
5. You enter a number in your computer. Write a program to check whether the number
entered by you, is a one digit number, a two digit number or a three digit number. Now
perform these tasks:
❖ If it is a one digit number then display its square.
❖ If it is a two digit number then display its square root.
❖ If it is a three digit number then display its cube root.
Otherwise, display the message “The number entered is more than three digits”
PROGRAM
class prg5
double p = 0;
else
}}
VARIABLE DESCRIPTION
DISTANCE RATE
Up to 5 km Rs. 100
Write a program to input the distance covered and calculate the amount paid by the
passenger.
PROGRAM
class prg6
int r=0;
if(d<=5)
r=100;
r=100 + (d-5)*10;
else
}}
VARIABLE DESCRIPTION
INPUT SCREEN
OUTPUT SCREEN
7. Write a menu driven program to perform the following tasks by using switch case
statement:
(a) To print the series:
0, 3, 8, 15, 24 ... to n terms (value of ‘n’ is to be an input by the user)
(b) To find the sum of the series:
1/2 + 3/4 + 5/6 + 7/8 + ………… + 19/20 .
PROGRAM
class prg7
switch(c)
case 1 :
int s = 0;
s=i*i - 1;
Break;
case 2:
double num=1.00,den=2.00;
{ double p =num/den;
sum=sum+p;
num+=2;
den+=2;
VARIABLE DESCRIPTION
OUTPUT SCREEN
8. Write two separate programs to generate the following patterns using iteration statements:
(a) * (b) 5 4 3 2 1
*# 5432
*#* 543
*#*# 54
*#*#* 5
PROGRAM
class prg8
void patterna()
for(int j =1;j<=i;j++)
if(j%2!= 0)
System.out.print("*");
else
System.out.print("#");
System.out.println();
void patternb()
int a=5;
for(int m=5;m>=0;m--)
a=5;
for(int n = m;n>0;n--)
System.out.print(a+" ");
a--;
System.out.println();
VARIABLE DESCRIPTION
OUTPUT SCREEN
9. Design a class to overload a function volume () as follows:
(i) double volume (double r): with radius (r) as an argument, returns the volume of sphere using
the formula
v=4/3* 22/7* r3
(ii) double volume (double h, double r): with height (h) and radius (r) as the arguments, returns
the volume of a cylinder using the formula
v=22/7 * r2 * h
(iii) double volume (double l, double b, double h): with length (l), breadth (b), and height (h) as
the arguments, returns the volume of a cuboid using the formula
v=l * b* h
PROGRAM
class overloading
{ double v=0.00;
double volume(double r)
v=4.00/3.00*22.00/7*r*r*r;
return v;
v=22.00/7.00*r*r*h;
return v;
v=l*b*h;
return v ;
Volume (r);
volume (h , r);
volume ( l, b , h);
VARIABLE DESCRIPTION
1-5000 5%
Write a program to input amount of purchase and find the discount and print the net
amount to be paid by the customer.
PROGRAM
class prg10shopping
dis=5.00/100.00* pamt;
dis=10.00/100.00 *pamt ;
dis=15.00/100.00 * pamt;
else
dis=20.00/100.00 * pamt ;
namt=pamt-dis;
System.out.println("Your net payable amount is : " + namt);
VARIABLE DESCRIPTION
INPUT SCREEN
OUTPUT SCREEN
11. Write a program to accept a number and display the new number after removing all
zeros.
Sample Input- 5400207
Sample Output- 5427
PROGRAM
class prg11zeros
void disp(long n)
{ long d = 0,rwz=0,x=0,og=0,co=n;
while(n>0)
d=n%10;
n=n/10;
if(d!=0)
rwz=rwz*10+d ;
while(rwz>0)
x=rwz%10;
rwz=rwz/10;
og=og*10+x;
System.out.println(" The original number is " + co + " and the number after removing all
the zeros is " + og);
}
VARIABLE DESCRIPTION
INPUT SCREEN
OUTPUT SCREEN
12. Write a program to accept a number and display the frequency of each digit present in
the
number
Sample Input- 341124
Sample Output- The frequency of 3 = 1
The frequency of 4 = 2
The frequency of 1 = 2
The frequency of 2 = 1
PROGRAM
class prg12frequency
void disp(int n)
for(int i =0 ;i<=9;i++)
c=0;
x=n;
while(x>0)
d=x%10;
x=x/10;
if(d==i)
c++;
if(c>0)
INPUT SCREEN
OUTPUT SCREEN
12. Write a program to accept a number and check whether the number is present in the
Fibonacci series or not. The program displays the message accordingly.
Sample Input: 55
Sample Output: 55 is present in the Fibonacci series.
PROGRAM
class FibonacciCheck {
int a = 0, b = 1;
if (a == num) {
return true;
int c = a;
a = b;
b = c + b;
return false;
void main(int n) {
if (isFibonacci(n)) {
} else {
INPUT SCREEN
OUTPUT SCREEN
14. A prime number is said to be “Twisted Prime”, if the new number obtained after
reversing
the digits is also a prime number. Write a program to accept a number and check whether the
number is “Twisted Prime” or not.
Sample Input- 167
Sample Output- 761
167 is a Twisted Prime Number
PROGRAM
class prg14
void main(int n)
else
boolean isprime(int m)
{ int c=0;
for(int i =1;i<=m;i++)
if(m%i==0)
c++;
if(c==2)
return true;
else
return false;
int twist(int q)
int d=0,copy=q,rev=0;
while(q>0)
d=q%10;
q=q/10;
rev=rev*10 + d;
return rev;
VARIABLE DESCRIPTION
OUTPUT SCREEN
PROGRAM
class prg15duck
void disp(int n)
int d,c=0;
while(n>0)
d=n%10;
if(d==0)
c++;
n=n/10;
if(c>0)
System.out.println("Duck Number");
else
}
VARIABLE DESCRIPTION
INPUT SCREEN
OUTPUT SCREEN
17. Define a class to accept a four-digit number and check if it is a USHWA number or not. The
number is said to be USHWA
Accept a four digit number, If:
Sum of all digits = 2*(Sum of first and last digits)
Example 1:
n=1234
Sum of first and last digits = 1+4 = 5
Sum of all digits = 1+2+3+4 = 10
Example 2:
If the input value is 354, then an error message should be given as the number has only 3 digits.
PROGRAM
class prg17
void disp(int n)
{ int co = n;
while(n>0)
d=n%10;
n=n/10;
sum=sum+d;
if(sum==pro)
else
else
{ int c = 0;
while(co>0)
co=co/10;
c++;
VARIABLE DESCRIPTION
OUTPUT SCREEN
18. Write a program to display all Mersenne numbers between 1.....n using the method
name
MersenneNos (int n) where n has to be in the range 1-10.
[Mersenne numbers are the ones which are one less than a power of 2, i.e., M (n) = 2n-1 where
n is an integer. Some Mersenne numbers are 0, 1, 3, 7, 15, 31, 63, etc....]
PROGRAM
class prg18mersenne
void MersenneNos(int n)
for(int j =0;j<=n;j++)
if(mersennecheck(j))
System.out.println(j);
else
boolean mersennecheck(int m)
{ int p =0,f=0;
for(int i=0;i<=m;i++)
p=(int)Math.pow(2,i)-1;
if(p==m)
f=1;
continue; }
if(f==1 )
return true;
else
return false ; } }
VARIABLE DESCRIPTION
OUTPUT SCREEN
19. Define a class Exchange described as below:
Instance Variables / Data Members
int a, b - to store two numbers
Member Methods
Exchange (int x, int y) - Parameterised constructor to assign value to member variables.
void display () - to display values before swapping and after swapping.
void swap() - to swap the numbers without using any third variable.
Write a main method to create an object of the class and call the above member methods
PROGRAM
class Exchange
int a;int b;
Exchange(int x , int y)
a=x;
b=y;
void swap()
a=a+b;
b=a-b;
a=a-b;
void display()
}
void main()
ob.display();
ob.swap();
ob.display();
VARIABLE DESCRIPTION
OUTPUT SCREEN
20. Write a program to display each number with its factorial within the range n to m, where
n<m.
[Factorial of 4 means 4! = 4*3*2*1 =24]
PROGRAM
class prg20fact
if(n>m)
else
int ch =checkfact(i);
int f =1;
int checkfact(int k)
for(int i =1 ;i<=k;i++)
f=f*k;
}
return f; } }
VARIABLE DESCRIPTION
INPUT SCREEN
OUTPUT SCREEN
21. Write a program to display the first 15 prime numbers
PROGRAM
class prg21primecheck
void disp ()
for(int k =1;k<=50;k++)
if(primechecker(k))
System.out.print(k+",");
boolean primechecker(int n)
for(i =1;i<=n;i++)
if(n%i==0)
c++;
if(c==2)
return true ;
else
return false ; } }
VARIABLE DESCRIPTION
OUTPUT SCREEN
22. Write a program to display all Palindromic numbers within the range 100 to 1000
PROGRAM
class prg22
boolean palindrome(int n)
int d=0,rev=0,co=n;
while(n>0)
d=n%10;
n=n/10;
rev=rev*10+d;
if(rev==co)
return true;
else
return false;
void main()
for(int i =1000;i<=9999;i++)
{
if(palindrome(i))
System.out.print(i+ ","); } } }
VARIABLE DESCRIPTION
OUTPUT SCREEN
23. Write a program to display all twin prime numbers within the range 1 to 1000.
PROGRAM
class TwinPrimeNumbers {
if (num <= 1) {
return false;
if (num % i == 0) {
return false;
return true;
void main() {
VARIABLE DESCRIPTION
OUTPUT SCREEN
24. Write a program to input a number and check and print whether it is a Pronic number or
not.
[Pronic number is the number which is the product of two consecutive integers.]
Example- 12= 3*4
20= 4*5
42= 6*7
PROGRAM
class prg24pronic
void disp(int n)
int x =(int)Math.sqrt(n);
int x1=x+1;
if(mul == n)
else
}
VARIABLE DESCRIPTION
OUTPUT SCREEN
25. Write a program to input a number from the user and check whether it is a Disarium
number or not.
[A number is said to be the Disarium number when the sum of its digits raised to the power of
their respective positions is equal to the number itself.]
Example 1: 175
11 + 72 + 53 = 1 + 49 + 125 = 175
Example 2: 89
81 + 92 = 8+81 = 89
PROGRAM
class prg25diarium
void disp(int n)
while(n>0)
n=n/10;
c++;
for(int i =c;i>=1;i--)
{ d=x%10;
x=x/10;
p =(int)Math.pow(d,i);
}
if(sum==e)
else
VARIABLE DESCRIPTION
OUTPUT SCREEN
NAME– RUDRANARAYAN HALDER
----------------------------------------------------------------------------------------------
SIGNATURE:
………………………………… ….……………………………….
(Internal Examiner) (External Examiner)