0% found this document useful (0 votes)
29 views

11 Project Computer 2024

Uploaded by

paulromit2020
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

11 Project Computer 2024

Uploaded by

paulromit2020
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

The Aryans School

Class -XI
COMPUTER SCIENCE
ASSIGNMENT (2024 – 25)
_ _

1. Write a program in Java to accept a decimal number and convert it equivalent binary, octal
(without using String & array) & hexadecimal form. Test your program forthe following data & some
random data.
(Use minimum complexity to convert the base value & don’t use any inbuilt methods)Class Name:

Number_System

Instance Method:

void binary (int dec) : to convert the decimal number to binaryvoid octal
(int dec) : to convert the decimal number to octal
void hexa (int dec) : to convert the decimal number to hexa-decimal

Sample Input: Enter the number: 123


Sample Output: Equivalent Binary form: 1111011Equivalent Octal
form: 173
Equivalent Hexadecimal form: 7B

2. Write a program in Java to display all the composite Fibonacci number between 1to ‘n’ (both
inclusive).
Composite Fibonacci No = 8, 34, 55 [The number that is a non-prime number &also a
Fibonacci Number]

Class Name: Comp_Fibo


Instance Variable: int n : to store the upper limit

Rest of the member variables can be assumed as required.

Instance Method:

Comp_Fibo ( ) : to initialize the variables.

void display (int num) : to display the Composite Fibonacci number.

boolean check_Composite (int n) : to check the ‘n’ is Prime or not, using bestmethod & if it is

Prime returns false otherwise returns true.

int chk_Fibo (int n) : to check the ‘n’ is Fibonacci or not (withoutusing 3rd

variable) if true returns 1 otherwise returns 0.

Write a main ( ) to test your class & call the methods using object.
3. Write a program in Java do the following task:

class name : complement


Member methods:
String binary(int n): accept a decimal number and return it’s binaryString
eight_bits(int n): return 8 bits binary number
void diplay(): print 1’s complement of input number

Create a main() method to input a number and enable the above task.

4. Write a program which will accept N words in Uppercase and display the frequency of the characters of each
word as per sequence they are present in the word.

Example:
Word: APPLICATION
Frequency of A: 2
Frequency of P: 2
Frequency of L: 1
Frequency of I: 2
Frequency of C: 1
Frequency of T: 1
Frequency of O: 1
Frequency of N: 1

5. Write a Java program to display all the amicable pairs between lower and upper range given by the user.
Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the
other number. Give appropriate message if no such pairs exists within the range. Also display the frequency of the
amicable pairs.
The first ten amicable pairs are: (220, 284), (1184, 1210), (2620, 2924), (5020, 5564), (6232, 6368), (10744, 10856),
(12285, 14595), (17296, 18416), (63020, 76084), and (66928, 66992).

6. Write a program which takes n integers as input(max 50 integers)


and stores them in an array data from index 0 to n-1.
Now we want to rearrange the integers in the following way:-
Find the minimum value and put it in position (n/2) [for odd number of elements] and position (n/2 -1)[ for even
number of elements]);
find the second smallest value and put it to its right;
then the third smallest and place it to its left

and so on altering right and left until all the integers are done.

Initial array:- (size:7) Initial array: (size:6)

7 3 1 6 4 2 5 7 3 1 6 4 2
After re-arrangement the array becomes
then after rearranging it becomes

7 5 3 1 2 4 6 6 3 1 2 4 7

7. Write a program to declare a matrix A[][] having order MxN( where M is no. of rows and N is no. of columns)
where values of both M and N must be greater than 2 and less than 10.Allow the user to accept value for matrix.
Perform the following tasks:
a) Display original matrix
b) Sort each odd row of the matrix in ascending order and each even row of the matrix in descending order
using any sorting algorithm.
c) Display the final updated matrix.

8. A Composite Magic number is a positive integer which is composite as well as a magic number. Composite
number: A composite number is a number that has more than two factors. Example: 10 Factors are: 1, 2, 5, 10
Magic number: A magic number is a number in which the eventual sum of the digits is equal to 1.

Example: 28 = 2+8 = 10 = 1+0 = 1 Accept two positive integers m and n, where m is less than n as user
input. Display the number of Composite Magic integers that are in the range between m and n (both inclusive)
and output them along with the frequency, in the format specified below:
Test your program for the following data and some random data.
Example 1
INPUT: m = 40 n = 100
OUTPUT:
THE COMPOSITE MAGIC INTEGERS ARE: 46, 55, 64, 82, 91, 100
FREQUENCY OF COMPOSITE MAGIC INTEGERS IS: 6

Class name: Number


Data members/instance variables:
num: to store the number
Methods/Member functions:
Number (int nn): parameterized constructor to initialize the data member num=nn int
count_of_factors(int i): returns the number of the factors (num), excluding itself, using a
recursive technique
int sum_of_digits(int i): returns the sum of the digits of the number(num),using a recursive technique

void check(): checks whether the given number is Composite Magic number by invoking the functions
and displays the result with an appropriate message
Define a main() function to create an object and call the functions accordingly to enable the task.
9. Write a program to declare a matrix A [ ] [ ] of order (M × N) where ‘M’ is the number of rows and ‘N’ is
the number of columns such that both M and N must be greater than 2 and less than10. Allow the user to
input integers into this matrix. Display appropriate error message for an invalid input. Perform the
following tasks on the matrix.
(a) Display the input matrix
(b) Rotate the matrix by 2700 degrees anti clock wise and display the resultant matrix (c) Calculate
the sum of the odd elements of the matrix and display
Test your program for the following data and some random data:
Example 1
INPUT: M = 3 N = 4
ENTER ELEMENTS: 8, 7, 9, 3,-2, 0, 4, 5, 1, 3, 6, -4
OUTPUT:
ORIGINALMATRIX
8793
-2 0 4 5
1 3 6 -4
ROTATED MATRIX ( 2700 ANTI CLOCK WISE )
1 -2 8 3
0764
9 -4 5 3
SUM OF THE ODD ELEMENTS = 28

10. A class called Date has been defined to handle Date related functions ie finding the number of days and show
the date when no.of days is given. Another method is required for some job where you input the day number and
it will show you the date in the current year 2023.
You can perform your job by using the following functions/methods of Date given below.

Class Name Date


Data members: dd - day
mm - month
Member function/methods :
Date(int nd, int nm) : constructor to initialize member data int dateTodateNumber(Date dt): returns
the dateNumber equivalent to the Date object dt. Date dateNumberToDate(int dn): returns the date
equivalent to the given dateNumber dn In year 2023
void display(): to display date in dd/mm format.
void accept(): to accept date in day number and valid month number from user.
Write the main() method to implement the logic..
Example :
Date(dd-mm) dateNumber
01-01 1
20-01 20
31-12 365
DateNumber Date
356 31-12
1 01-01
11. Design a class StringModify in your default package that will contain methods that will work on string values.
The method definitions of the class is given below:
i) StringModify(String st): parameterized constructor
ii) String insertStringAt(String w,int pos): to insert string w at valid position pos and returns final sentence
without changing any other data.

iii) String deleteCharAt(char w,int pos): to delete character w from valid position pos and returns final
sentence without changing any other data.
Write a menu driven program using switch case in main method to implement the above logic for any random
sentence by calling methods.

12. Write a program to accept a sentence which may be terminated by either ‘. ‘ or ?’ or ‘!’ only. Any other character
may be ignored. The words may be separated by more than one blank space and are in UPPER CASE. Perform the
following tasks: (a) Accept a sentence and remove all the extra blank space between two words to a single blank
space. (b) Accept any word from the user along with its position and insert the word in the given position. (The
position is calculated by place value of each word where first word is in position 1, second word in position 2 and so
on). c) Display the modified sentence. Test your program for the following data and some random data.:
Example
INPUT: MORNING WALK IS A BLESSING FOR THE WHOLE DAY.
WORD TO BE INSERTED: TOTAL
WORD POSITION IN THE SENTENCE: 5
OUTPUT: MORNING WALK IS A TOTAL BLESSING FOR THE WHOLE DAY.

13. Write a Java program to check whether a given number is a Disarium number or unhappy number. A

Disarium number is a number defined by the following process :

Sum of its digits powered with their respective position is equal to the original number. For
example 175 is a Disarium number :
As 11+32+53= 135
Some other DISARIUM are 89, 175, 518 etc.

A number will be called Disarium if the sum of its digits powered with their respective position is equal with
the number itself.

Happy number: Starting with any positive integer, replace the number
by the sum of the squares of its digits, and repeat the process until the
number equals 1, or it loops endlessly in a cycle which does not
include 1.
An unhappy number is a number that is not happy.
14. Write a program to declare a square matrix M[ ] [ ] of order (N x N) where `N' must be greater than 3 and less
than 10. Allow the user to input positive integers into this matrix.
Perform the following tasks on the matrix:
(a) Sort the boundary elements in ascending order using any standard sorting technique and rearrange them
in the matrix in clockwise manner.
(b) Calculate the product of the non-boundary elements.
(c) Display the original matrix, rearranged matrix and only the non-boundary elements of the rearranged
matrix with their sum.
Test your program for the following data and some random data:
15. Write a program to declare a square matrix M [ ] [ ] of order ‘N’ where ‘N’ must be greater than 3 and
less than Accept the value of N as user input. Display an appropriate message for an invalid
input. Allow the user to accept three different characters from the keyboard and fill the matrix according
to the instruction given below:
(i) Fill the four corners of the square matrix by character 1
(ii) Fill the boundary elements of the matrix (except the four corners) by character 2 (iii) Fill the non-
boundary elements of the matrix by character 3 (iv) Display the matrix formed by the above
instructions Test your program for the following data and some random data:

You might also like