2. ACKNOWLEDGEMENT
I would like to thank my
teachers and friends for
motivating me to complete this
project. Special gratitude to my
Computer teacher Mr. Sarfarz Sir
for providing the guidelines of
the project and solving all my
queries regarding this project.
Thank you.
4. Define a class matrix to sort and determine the largest and the
smallest element with the following details:
Data members/ Instance variables
Mat[][]: an integer array to store the elements
int r, int c : to store size of an array
Member Functions:
Matrix( int m ,int n): Constructor to initialize instance variable
and create array.
void read() : input elements of array
void sort(Matrix A): sorts the elements present in Matrix A in
ascending order and stores the rest in mat of current object
void display(): print mat in form of matrix
Also define the main function to initiate the above tasks.
5. import java.util.Scanner;
public class Matrix
{
int Mat[][]; int r, c;
Matrix(int m , int n)
{
r=m;
c=n;
Mat = new int [r][c]; }
void read()
{
Scanner sc = new Scanner (System .in);
for (int i =0; i<r; i++)
{ System.out.println(“ ENTER ELEMENTS”);
Mat[i][j]= sc.nextInt();
}}
void sort()
{
6.
7.
8. int arr[]= new int [A.r * A.c];
Int k =0;
for(int i = 0; i<A.r;i++)
for( int j=0; j<A.c;j++)
arr[k++]=A mat[i][j];
int n =A.r*A.c;
for(int i =0;i<n-1;i++)
for(int j =0; j<n-1;j++)
If (arr[j]>arr{j+1])
{int temp= arr[j];
arr[j] =arr[j+1];
arr[j+1]= temp;}int k=0;
for(int i=0; i<A.r;i++)
for(int j =0; j <A.c;j++)
this Mat[i][j]= arr[k++];
this.r= A.r;
this.c= A.c;
}
void display()
11. A class no. has been defined to find the frequency of the following of each digit present in
the number, sum of digits at even numbered position and to display results
Class Name : Number
Data Members/ Instance Variables :
Num: long integer type
Member function
Number( ): default constructor
Number(long n): parameterized constructor to initialize num
void digitfrequency (): to find the frequency of each digit present in the number and display
it.
void sumdigit(): to find the sum of digits at even numbered position (with unit place).
Also define the main function .
import java.util.Scanner;
public class Number{
Long num;