0% found this document useful (0 votes)
41 views5 pages

ASSIGNMENT Teacherapptempdocument1000041559 20231120163855

1. This document outlines 10 classes with their data members, constructors, and methods to perform various tasks related to arrays, strings, matrices, and number properties. 2. The classes include Composite to find composite numbers, Line to check if a point lies on a line, TheString to analyze a string, Sort to alphabetize words, ConsChange to modify words, Clck to rotate a matrix, Matrix to calculate matrix multiplication, ArrayMax to find maximum row values, and Prime to fill an array with prime numbers. 3. Main methods are provided to create objects and call class methods to implement the described functionality for each class.

Uploaded by

Shibi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views5 pages

ASSIGNMENT Teacherapptempdocument1000041559 20231120163855

1. This document outlines 10 classes with their data members, constructors, and methods to perform various tasks related to arrays, strings, matrices, and number properties. 2. The classes include Composite to find composite numbers, Line to check if a point lies on a line, TheString to analyze a string, Sort to alphabetize words, ConsChange to modify words, Clck to rotate a matrix, Matrix to calculate matrix multiplication, ArrayMax to find maximum row values, and Prime to fill an array with prime numbers. 3. Main methods are provided to create objects and call class methods to implement the described functionality for each class.

Uploaded by

Shibi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Second Term Revision Programs-December 2023

1. A class composite is designed to print composite numbers between start


and the last limit
Class name: Composite
Data members/instance variables:
m,n: to store the start and last limit
count: stores the count of composite numbers.
Member methods:
void input(): to input start and last limits
int iscomposite(int x): returns 1 if the parameter value ‘x’ is a composite
number otherwise 0.
void show(): by invoking int iscomposite() print all composite numbers
along with the count between m and n both inclusive if m>n, print the
message “Limits out of range”.Write a main method.
2. A class Line has been defined with the following description
Class name:Line
Data members/Instance variables:
int a,b,c,x,y: integers to store the coefficients a,b,c and the coordinates of
a point x,y of a line ax+by+c=0
void getpoint(): to input the values of a,b,c,x,y
boolean ison(): verifies whether it satisfies the equation and returns true
else returns false.
void show(): to display the coefficients a,b,c and the coordinates x,y. and
to display whether the current point is on the line, by invoking ison().
Write a main method.

3. A class TheString accepts a string of a maximum of 100 characters with


only one blank space between the words. Some of the members of the
class are as follows:-
Class name : TheString
Data members
str : to store a string
len : integer to store the length of a string
wordcount : integer to store the number of words
cons : integer to store the number of consonants
Member functions
TheString() : default constructor to initialize the data members
TheString(String ds) : parameterized constructor to assign str=ds
voidcountFreq() : to count the number of words and number of consonants and
store them in wordcount and cons respectively.
void Display() : to display the original string, along with the number of words
and the number of consonants.
Specify class TheString giving details of the constructors, void countFreq() and
void Display(). Define the main( ) function to create an object and call the
functions accordingly to enable the task.
4. Design a class Sort which enables a word to be arranged in alphabetical
order. The details of the members of the class are given below:-
Class Name : Sort
Data Members
str : stores a word
len : to store the length of the word
Member functions
Sort ( ) : default constructor
voidreadword( ) : to accept the word
void arrange( ) : to arrange the word in alphabetical order using any standard
sorting technique.
void display() : displays the original word along with the sorted word.
Specify class Sort giving details of the constructor, void readword(), void
arrange() and void display().
Define the main function to create an object and call the functions accordingly
to enable the task
5. A class consChange has been defined with the following details:
Class name : ConsChange
Data Members
word : stores the word
len : stores the length of the word
Member functions
ConsChange( ) : default constructor
void readword( ) : stores the word in word that is accepted from the user
void shiftcons( ) : shifts all the consonants of the word at the beginning
followed by the vowels ( eg. Spoon becomes spnoo)
void changeword( ) : changes the case of all occurring consonants of the shifted
word to uppercase, for eg. Spnoo becomes SPNoo).
void show( ) : displays the original word, shifted word and the changed word.
Specify class ConsChange giving the details of the constructor( ), void
readword(),void shiftcons(), void changeword( ) and void show( ). Defne the
main function to create an object and call the functions accordingly to enable
the task.
6.

7. A class ArrayMax contains a square matrix which finds the largest


element in each row.
Some of the members of the class are given below:
Class name : ArrayMax
Data member/instance variable:
arr[ ][ ] : array to store integer elements
m : to store the order of the matrix
Member functions/methods:
ArrayMax( int mm) : parameterized constructor to initialize the data
member m=mm and to declare the array
void readarray() : to accept the array elements
void large( ) : finds and displays the largest element in each row
with an appropriate message
void display() : displays the array elements in matrix form
Specify the class ArrayMax, giving the details of the constructor( ), void
readarray( ), void large( ) and void display( ). Define the main( ) function to
create an object and call the functions accordingly to enable the task.
8. A square matrix of type integer and of order mxm if filled with random
numbers. It can be rotated by 900 clockwise.
Example input: m=3 Matrix 900 clockwise
123 741
456 852
789 963
A class named Clck has been designed some of the members of the class are
given below:
Class name: Clck
Instance variables:
int m: to store the number of rows and columns
int tma[][]: a two dimensional array of order m x m.
Member methods:
Clck(int mm): parameterised constructor to store m=mm and the initialise
the array
void fnread( ): method to fill the member array with integers
void fnrotate(): modify the member matrix by rotating it by 900 clockwise as
shown.
void fnshow(): to print the member array as matrix
Specify the class Clck giving details of the constructors and methods. Write
a main method.

9. A class Matrix calculates the product of two matrices . some of the


members of the class are as follows
Class name: Matrix
Instance variables:
int m: to store the number of rows and columns
int a[][], int b[][]: to store the elements of two matrices
int c[][]: to store the product of two matrices
Member methods:
Matrix(int mm): parameterised constructor to store m=mm and the initialise
both the arrays
void read(): to input the elements of both the matrices
void calc(): to calculate the product of two matrices.
void show(): to display the product of the two matrices.
Specify the class Matrix giving details of the constructors and methods.
Write a main method.
10.Design a class Prime to fill an array of order [m x n ] where the maximum
value of both m and n is 20, with the first [m x n ] prime numbers Row
wise . The details of the members of the class are given below:
Class name : Prime
Data members / instance variables :
arr[ ][ ] : Two dimensional integer array.
r : integer to store the number of rows.
c : integer to store the number of columns.
Member functions :
Prime(…….. ) : to accept the size of the array.
int isprime ( int p ) : return 1 if number is prim and 0 if not prime.
void fill ( ) : to fill the elements of the array with the first (m x n )
prime numbers.
void display ( ) : displays the array the array in a matrix form.
Specify the class Prime giving details of the constructor and member
functions int isprime (int), void fill( ) and void display( ) with main( )
function to create an object and call the function accordingly.

You might also like