The Programming Project

Tuesday, August 5, 2014

ISC COMPUTER SCIENCE PRACTICAL– 2000 Days Elapsed, ISC JAVA PROGRAMS

ISC COMPUTER SCIENCE PRACTICAL– 2000 Days Elapsed, ISC JAVA PROGRAMS
Write a program to input two valid dates, each comprising of day (2 digits), Month (2
digits) and year (4 digits) and calculate the days elapsed between the two dates.
Test your program for the following data values:

i) FIRST DATE : DAY : 24
        MONTH: 09
        YEAR: 1960
   SECONDDATE : DAY : 08
        MONTH: 12
        YEAR: 1852
       
ii) FIRST DATE : DAY : 10
        MONTH: 01
        YEAR: 1852
   SECONDDATE : DAY : 16
        MONTH: 10
        YEAR: 1952                
      
import java.util.*;
import java.io.*;
public class DaysElapsed {
    public static void main(String[] args) throws IOException {
        int day,month,year;
        int day1,month1,year1;
        boolean flag;
        Scanner in = new Scanner(System.in);
        DaysCalculation date = new DaysCalculation();
        DaysCalculation date1 = new DaysCalculation();
        do {
            System.out.println("INPUT THE FIRST DATE:");
            System.out.println("INPUT DAY:");
            day = in.nextInt();
            System.out.println("INPUT MONTH:");
            month = in.nextInt();
            System.out.println("INPUT YEAR:");
            year = in.nextInt();
            flag = date.checkDate(day,month,year);
            if (flag == false)
                System.out.println("INVALID,DATE,INPUT AGAIN");
            } while(flag != true);
        date.setDate(day,month,year);   
        do {
            System.out.println("INPUT THE SECOND DATE:");
            System.out.println("INPUT DAY:");
            day1 = in.nextInt();
            System.out.println("INPUT MONTH:");
            month1 = in.nextInt();
            System.out.println("INPUT YEAR:");
            year1 = in.nextInt();
            flag = date1.checkDate(day1,month1,year1);
            if (flag == false)
                System.out.println("INVALID,DATE,INPUT AGAIN");
            } while(flag != true);   
        System.out.println("DAYS ELAPSED:"+date.countDays(day1,month1,year1));       
        }
    }
class DaysCalculation {
    public void setDate(int d, int m, int y ){
        day = d;
        month = m;
        year = y;
        }
    public int countDays(int day1, int month1, int year1 ){
        int daysCount = 0;
        int y=0,y1=0;
        boolean small = false;
        if (year == year1)
            if (month == month1)
                if (day < day1)
                    small = true;
                else
                    small = false;       
            else if ( month < month1)
                small = true;
            else
                small = false;           
        else if( year < year1)
            small = true;
        else
            small = false;
        if (small == false) {
            int td,tm,ty;
            td = day;
            day = day1;
            day1 = td;
            tm = month;
            month = month1;
            month1 = tm;
            ty = year;
            year = year1;
            year1=ty;
            }   
        if (checkLeap(year) == true) {
                y += (ldays[month-1]-day);
                for ( int i = month; i <=11;i++)
                    y +=ldays[i];
                }
            else    {
                y += (mdays[month-1]-day);
                for ( int i = month; i <=11;i++)
                    y +=mdays[i];
                }    
            if (checkLeap(year1) == true) {
                y1 += day1-1;
                for ( int i = 0; i <month1-1;i++)
                    y1 +=ldays[i];
                }
            else    {
                y1 += day1-1;
                for ( int i = 0; i <month1-1;i++)
                    y1 +=mdays[i];
                }   
            for ( int i = year+1; i <= year1-1; i++) {
                if(checkLeap(i) == true)
                    daysCount +=366;
                else
                    daysCount +=365;
                }    
            if (year == year1)
                if (checkLeap(year) == true)
                    daysCount = y1-(366-y);
                else   
                    daysCount = y1-(365-y);   
            else    {
                daysCount += (y1+y);
                }           
        return daysCount;           
        }
    public boolean checkDate(int day, int month, int year) {
        if (checkLeap(year) == true) {
            if( 1 <= month && month <=12) {
                if(day>ldays[month-1] || day < 1 )
                    return false;
                else
                    return true;   
                }
            else
                return false;   
            }
        else {
            if( 1 <= month && month <=12) {
                if(day>mdays[month-1] || day < 1 )
                    return false;
                else
                    return true;   
                }
            else
                return false;   
            }
           
        }
    private boolean checkLeap(int year) {
        if(year%400==0)
           leap=true;
        else if (year%100==0)
           leap=false;
        else if (year%4==0)
           leap=true;
        else
           leap=false;
           return leap;
        }    
    private boolean flag;
    private static boolean leap;   
    private int day,month,year;
    private int daysCount;
    int[] mdays={31,28,31,30,31,30,31,31,30,31,30,31};
    int[] ldays={31,29,31,30,31,30,31,31,30,31,30,31};   
    }       

Monday, August 4, 2014

ISC COMPUTER SCIENCE PRACTICAL– 2000 DIAMOND SHAPE PATTERN

ISC COMPUTER SCIENCE PRACTICAL– 2000 DIAMOND SHAPE PATTERN, ISC JAVA PROGRAMS
Write a program to print a rectangle with diamond shape gap exactly at the centre of
the rectangle, using an input string with odd number of characters, not exceeding 20.

For example:

INPUT:

HAPPY-HAPPY
OUTPUT:

HAPPY HAPPY
HAPP      APPY
HAP           PPY
HA               PY
H                   Y
HA               PY
HAP           PPY
HAPP      APPY
HAPPY HAPPY

INPUT:

ISCPRAC*ISCPRAC

OUTPUT:

ISCPRAC ISCPRAC
ISCPRA     SCPRAC
ISCPR         CPRAC
ISCP              PRAC
ISC                  RAC
IS                       AC
I                            C
IS                       AC
ISC                  RAC
ISCP              PRAC
ISCPR         CPRAC
ISCPRA    SCPRAC
ISCPRAC ISCPRAC



import java.util.*;
import java.io.*;
public class DiamondShape {
    public static void main(String[] args) throws IOException {
        String msg;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));   
        System.out.println(" Enter the sentence:");
        msg = br.readLine();
        while ( msg.length() > 20 || (msg.length())%2 == 0) {
            System.out.println("INCORRECT FORMAT, INPUT AGAIN:");
            msg = br.readLine();
            }
        Pattern pt = new Pattern(msg);
        System.out.println("OUTPUT:");
        pt.patternPrint();
        }
    }   
class Pattern {
    Pattern(String msg) {
        inputMsg = msg;
        middle = (inputMsg.length()-1)/2;
        reverse = new String[middle+2];
        }
    public void patternPrint() {
       
        int index,temp = middle+1;
        index = temp;
        reverse[index] += inputMsg;
        for ( int i = middle; i > 0; i--) {  // loop to print the pattern till we have one character at left and one at right **
            reverse[index-1] = "";
            for ( int j = 0; j <= middle; j++) { // loop to print left half from the centre
                if ( j > i-1) {
                    System.out.print(" ");
                    reverse[index-1] += " ";
                    }
                else {   
                    System.out.print(inputMsg.charAt(j));
                    reverse[index-1] += inputMsg.charAt(j);
                    }
                }   
            for ( int k = middle+1; k < inputMsg.length(); k++) { // loop to print right half from the centre
                if( k < temp ) {
                    System.out.print(" ");
                    reverse[index-1] += " ";
                    }
                else {   
                    System.out.print(inputMsg.charAt(k));   
                    reverse[index-1] += inputMsg.charAt(k);
                    }
                }
            temp++;   
            index--;
            System.out.println();            
            }
        for ( int i = 2; i < middle+1; i++) // once the loop ** is completed we just print the string in reverse order to get the pattern
            System.out.println(reverse[i]);
       
        }   
    private String inputMsg;
    private String[] reverse;
    private int middle;
    }   

Sunday, August 3, 2014

ISC COMPUTER SCIENCE PRACTICALS 2008 ~ Matrix Sort and Largest two elements



ISC COMPUTER SCIENCE PRACTICALS 2008 ~ Matrix Sort and Largest two elements

Given a square matrix list [ ] [ ] of order ‘ n ’. The maximum value possible for ‘ n ’
is 20. Input the value for ‘ n ’ and the positive integers in the matrix and perform the
following task:

1. Display the original matrix
2. Print the row and column position of the largest element of the matrix.
3. Print the row and column position of the second largest element of the
matrix.
4. Sort the elements of the rows in the ascending order and display the new
matrix.

Sample data:
INPUT
N = 3
List [] [ ]
5    1    3
7    4    6
9    8    2

OUTPUT

5    1    3
7    4    6
9    8    2

The largest element 9 is in row 3 and column 1
The second largest element 8 is in row 3 and column 2
Sorted list
1    3    5
4    6    7
2    8    9  

import java.util.*;
public class MatrixfirstSecond {
    public static void main(String[] args) {
        int M;
        Scanner in = new Scanner(System.in);
        System.out.println("INPUT THE ORDER OF THE MATRIX:");
        M = in.nextInt();
        while( M > 20 || M < 1 ) {
            System.out.println("OUT OF RANGE, INPUT AGAIN:");
            M = in.nextInt();
            }
        Sorting cm = new Sorting(M);
        cm.inputElements();
        System.out.println();
        cm.displayMatrix();
        System.out.println();   
        cm.maxMin();
        System.out.println();
        cm.rowSort();
        }
    }
class Sorting {
    Sorting(int M) {
        row = M;
        column = M;
        Mat = new int[row][column];
        }
    public void inputElements() {
        System.out.println("Enter the elements of the matrix:");
        Scanner in = new Scanner(System.in);
        for(int i = 0; i < row; i++) {
            for(int j = 0; j < column; j++) {
                System.out.println("Input the element:");
                Mat[i][j] = in.nextInt();
                }
            }
        }   
    public void displayMatrix() {
        System.out.println("ORIGINAL MATRIX:");
        for(int[] i : Mat) {
            for(int j : i) {
                System.out.print(j+"  ");
                }
            System.out.println();
            }
        }   
    public void maxMin() {
        boolean flag = false;
        max = secondMax = Mat[0][0];
        for(int i = 0; i < row; i++) { // largest
            for(int j = 0; j < column; j++) {
                if(Mat[i][j] >= max ) {
                    max = Mat[i][j];
                    maxrowPosition = i+1;
                    maxcolPosition = j+1;
                    }
                }
            }
        for(int i = 0; i < row; i++) { // Second largest
            for(int j = 0; j < column; j++) {
                if(Mat[i][j] >= secondMax && Mat[i][j] < max ) {
                    flag = true;
                    secondMax = Mat[i][j];
                    secondMaxrowPosition = i+1;
                    secondMaxcolPosition = j+1;
                    }
                }
            }   
        if( flag == false) {
            secondMax = max;
            secondMaxrowPosition = maxrowPosition;
            secondMaxcolPosition = maxcolPosition;
            }
        System.out.println("The largest Number: "+max);
        System.out.println("Row: "+maxrowPosition);
        System.out.println("Coloumn: "+maxcolPosition);   
        System.out.println("The second largest Number: "+secondMax);
        System.out.println("Row: "+secondMaxrowPosition);
        System.out.println("Coloumn: "+secondMaxcolPosition);
        }
    public void rowSort() {   
        int[] temp = new int[row];
        int k = 0;
        System.out.println("SORTED LIST:");
        for(int i = 0; i < row; i++) {
            for(int j = 0; j < column; j++) {
                temp[k++] = Mat[i][j];
                }
            k = 0;
            Arrays.sort(temp);
            for( int l = 0; l < row ;l++)
                System.out.print(temp[l]+"  ");    
            System.out.println();
            }   
        }   
    private int[][] Mat;   
    private int row;
    private int column;
    private int max;
    private int secondMax;
    private int maxrowPosition;
    private int maxcolPosition;
    private int secondMaxrowPosition;
    private int secondMaxcolPosition;
    }   

Saturday, August 2, 2014

ISC COMPUTER SCIENCE PRACTICALS 2008 ~ Vowels & Words Count



ISC COMPUTER SCIENCE PRACTICALS 2008 ~ Vowels & Words Count in Strings
A sentence is terminated by either “ . ” , “ ! ” or “ ? ” followed by a space.
Input a piece of text consisting of sentences. Assume that there will be a
maximum of 10 sentences in a block.
Write a program to:
(i)  Obtain the length of the sentence (measured in words) and the frequency
     of vowels in each sentence.
(ii) Generate the output as shown below using the given data

Sample data:

INPUT
HELLO! HOW ARE YOU? HOPE EVERYTHING IS FINE. BEST OF LUCK.
OUTPUT

Sentence    No. of Vowels    No. of words
----------------------------------------------------------
1        2        1
2        5        3 
3        8        4
4        3        3       

import java.util.*;
import java.io.*;
public class StringVowelcount {
    public static void main(String[] args) throws IOException
        {
        Sorting fc = new Sorting();
        String msg;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));   
        System.out.println(" Enter the sentence:");
        msg = br.readLine();
        if ( msg.charAt(msg.length()-1) != '.' && msg.charAt(msg.length()-1) != '?' && msg.charAt(msg.length()-1) != '!' ) {
            System.out.println("Paragraph terminated incorrectly, appending '.' at the end");
            msg += '.';   
            }
        Vowel v = new Vowel(msg);
       
        v.senCount();
        v.sentenceExtraction();
        System.out.println("Sentence    No. of Vowels    No. of words");
        System.out.println("--------------------------------------------------------");
        v.vowelWordCount();
        System.out.println("");
        }
    }
class Vowel {
    Vowel(String msg) {
    paragraph  = msg;
    wordCount  = new int[paragraph.length()-1];
    vowelCount = new int[paragraph.length()-1];
    sentenceCount = 0;
    }
    public void senCount() {
        for ( int i = 0; i < paragraph.length(); i++) {
            if( paragraph.charAt(i) == '.' || paragraph.charAt(i) == '?' || paragraph.charAt(i) == '!' )
                sentenceCount++;
            }
        sentences = new String[sentenceCount];
        }
    public void sentenceExtraction() {
        int j = 0;
        System.out.println("The sentences are:");
        for ( int i = 0; i < paragraph.length(); i++) {
            sentences[j] = "";
            while(paragraph.charAt(i) != '.' && paragraph.charAt(i) != '?' && paragraph.charAt(i) != '!') {
                sentences[j] += paragraph.charAt(i);
                i++;
                if ( i == paragraph.length())
                    break;
                }
            sentences[j] += paragraph.charAt(i);   
            System.out.println(sentences[j]);
            j++;
            i++;
            }
         }   
    public void vowelWordCount() {
        String tmp;
        for (int i = 0; i < sentenceCount; i++) {
            wordCount[i] = 1;
            vowelCount[i] = 0;
            tmp = sentences[i].toUpperCase();
            for (int j =0; j < sentences[i].length(); j++) {
                if ( tmp.charAt(j) == ' ')
                    wordCount[i]++;
                if ( tmp.charAt(j) == 'A' || tmp.charAt(j) == 'E' || tmp.charAt(j) == 'I' ||tmp.charAt(j) == 'O' ||tmp.charAt(j) == 'U')   
                    vowelCount[i]++;
                }
            System.out.println(i+1+"        "+vowelCount[i]+"        "+wordCount[i]);   
            }
        System.out.println("");   
        }   
    private int sentenceCount; 
    private int[] wordCount;
    private int[] vowelCount;
    private String paragraph;
    private String[] sentences;   
    }

ISC COMPUTER SCIENCE PRACTICAL 2005 ~ WORD SORT on Length

ISC 2005 Computer Science practical solved paper

Write a program which takes a string (maximum 80 characters) terminated by a full stop.
The words in this string are assumed to be separated by one or more blanks.
Arrange the words of the input string in descending order of their lenghts.
Same length words should be sorted alphabetically.
Each word must start with an uppercase letter and the sentence should be terminated by a full stop.

Test your program for the following data and some random data.

SAMPLE DATA:
INPUT:
This is human resource department.

OUTPUT:
Department Resource Human This Is.

INPUT:
To handle yourself use your head and to handle others use your heart.

OUTPUT:
Yourself Handle Handle Others Heart Head Your Your And Use Use To To. 


import java.util.*;
import java.io.*;
public class LengthSort {
    public static void main(String[] args) throws IOException
        {
        Sorting fc = new Sorting();
        String msg;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));   
        System.out.println(" Enter the sentence:");
        msg = br.readLine();
        if ( msg.charAt(msg.length()-1) != '.')
            System.out.println("Incorrect format, still we are sorting for you!");
        fc.setMsg(msg);
        System.out.println("OUTPUT:");
        fc.totalWords();
        fc.wordExtraction();
        fc.output();
        System.out.println("");
        }
    }   
class Sorting {
    Sorting()
        {
        msg = " ";
        words = 0;
        }
    public void setMsg(String s) {   
        msg = s;
        len = s.length();
        }
    public void totalWords() {
        for ( int i =0; i<len ; i++)
            if(msg.charAt(i) == ' ')
                words++;
        wrdsCollection = new String[words+1];   
        for(int i = 0; i< words+1 ; i++ )
            wrdsCollection[i]= " ";
        }   
    public void wordExtraction() { 
        int j=0;
        for ( int i =0; i<len ; i++) {
            while(msg.charAt(i) != ' ')
                {
                if(msg.charAt(i) == '.')
                    { i++;
                    if(i>len-1)
                        break;
                    continue;
                    }
                wrdsCollection[j] +=msg.charAt(i);
                i++;
                if(i>len-1)
                    break;
                if((msg.charAt(i) == ' ')|| i >len-1)
                    break;
                }
            if(i>len-1)
                break;   
            j++;
            }
        }   
    public void output() {
    System.out.println("Rearranged Sentence:");
        for(int j = 0; j < wrdsCollection.length; j++) {
            for(int i = j+1; i < wrdsCollection.length; i++) {
                if(wrdsCollection[i].length() >= wrdsCollection[j].length()  ) {
                    if ( wrdsCollection[i].length() == wrdsCollection[j].length()) {
                        if(wrdsCollection[i].compareTo(wrdsCollection[j]) > 0) {
                            String temp = wrdsCollection[j];
                            wrdsCollection[j] = wrdsCollection[i];
                            wrdsCollection[i] = temp;
                            }
                        }
                    String temp = wrdsCollection[j];
                    wrdsCollection[j] = wrdsCollection[i];
                    wrdsCollection[i] = temp;
                    }
                }
            System.out.print(wrdsCollection[j]+" ");
            }   
        }   
    private String[] wrdsCollection;
    private int[] freCount;           
    private int len;
    private String msg;
    private int words;
    private boolean flag;   
    }

ISC COMPUTER SCIENCE PRACTICALS SOLVED ~ 2008 ~ SMITH Number

/*A smith number is a composite number, the sum of whose digits is the sum of
the digits of its prime factors obtained as a result of prime factorization
(excluding 1). The first few such numbers are 4, 22, 27, 58, 85, 94, 121 ...

Example;
1. 666
Prime factors are 2, 3, 3 and 37
Sum of the digits are (6+6+6) = 18
Sum of the digits of the factors (2+3+3+(3+7) = 18

2. 4937775
Prime factors are 3, 5, 5, 65837
Sum of the digits are (4+9+3+7+7+7+5) = 42
Sum of the digits of the factors (3+5+5+(6+5+8+3+7) = 42

Write a program to input a number and display whether the number is a Smith
number or not.
Sample data:

Input         Output
94        SMITH Number

Input        Output
102        NOT SMITH Number

Input        Output
666        SMITH Number

Input        Output
999        NOT SMITH Number

ISC COMPUTER SCIENCE PRACTICALS SOLVED ~ 2008 */

import java.util.*;
public class SmithNumber {
    public static void main(String[] args) {
        int N;
        Scanner in = new Scanner(System.in);
        System.out.println("Enter the number");
        N = in.nextInt();
        SmithCheck sc = new SmithCheck(N);
        if(sc.sumOfdigits(N) == sc.primeFactors())
            System.out.println("SMITH Number");
        else
            System.out.println("Not SMITH Number");   
        }
    }
class SmithCheck {
    SmithCheck(int N) {
        Numb = N;
        primefactorsSum = 0;
        }
    public int sumOfdigits(int n) {
        dSum = 0;
        sNumb = ""+n;
        for ( int i = 0; i < sNumb.length(); i++) {
            dSum += sNumb.charAt(i)-48;
            }
        return dSum;   
        }    
    public int primeFactors() {
        int Ntemp,count;
        for ( int j = 2; j <= Numb; j++) {       
            Ntemp = Numb;
            count = 0;
            if ( SmithCheck.isFactor(j) == true && SmithCheck.isPrime(j) == true ) {
                while ( Ntemp%j == 0) {
                    count++;
                    Ntemp /= j;
                    }
                primefactorsSum += count*sumOfdigits(j);       
                }
            }
        return primefactorsSum;   
        }   
    public static boolean isFactor(int n) {
        return ( Numb % n == 0 ? true : false );
        }   
    public static boolean isPrime(int n) {
        flag = false;
        for ( int j = 2; j <= Math.sqrt(n); j++) {
                if( n%j == 0) {
                    flag = true;
                    break;
                    }
                }
            return (flag == true ? false : true);
        }   
    private static boolean flag;   
    private static int Numb;
    private int dSum;
    private int primefactorsSum;
    private String sNumb;   
    }       

Friday, August 1, 2014

ISC COMPUTER SCIENCE PTRACTCALS ~ 2014 Symmetric Matrix

/*
Write a program to declare a square matrix A[][] of order MxM where ‘M’ is the number of rows
and the number of columns, such that M must be greater than 2 and less than 10. Accept the value
of M as user input. Display an appropriate message for an invalid input. Allow the user to input
integers into this matrix. Perform the following tasks:
a) Display the original matrix.
b) Check if the given matrix is symmetric or not. A square matrix is said to be symmetric, if
the element in the i th row and j th column is equal to the element of the j th row and i th
column.
c)
Find the sum of the elements of left diagonal and the sum of the elements of right diagonal
of the matrix and display them.
Test your program for the following data and some random data:
Example 1INPUT:
M= 3
1 2 3
2 4 5
3 5 6
OUTPUT:
ORIGINAL MATRIX
1 2 3
2 4 5
3 5 6
THE GIVEN MATRIX IS SYMMETRIC
The sum of the left diagonal = 11
The sum of the right diagonal = 10
Example 2
INPUT:
M= 4
7 8 9 2
4 5 6 3
8 5 3 1
7 6 4 2
OUTPUT:
ORIGINAL MATRIX
7 8 9 2
4 5 6 3
8 5 3 1
7 6 4 2
THE GIVEN MATRIX IS NOT SYMMETRIC
The sum of the left diagonal = 17
The sum of the right diagonal = 20
Example 3
INPUT:
M= 12
OUTPUT:
THE MATRIX SIZE IS OUT OF RANGE
*/
    /* ISC COMPUTER SCIENCE PRACTICALS SOLVED 2014 ~ Symmetric Matrix */
import java.util.*;
public class SymmetricMatrix {
    public static void main(String[] args) {
        int M;
        Scanner in = new Scanner(System.in);
        System.out.println("INPUT THE VALUE OF M:");
        M = in.nextInt();
        while( M > 10 || M < 2) {
            System.out.println("OUT OF RANGE, INPUT AGAIN:");
            M = in.nextInt();
            }
        Matrix m = new Matrix(M);   
        m.inputMatrix();
        System.out.println("OUTPUT:");
        m.displayMatrix();
        m.diagonalSum();
        in.close();
        }
    }   
class Matrix {
    Matrix(int M) {
        odr = M;
        Mat = new int[M][M];
        leftDsum = 0;
        rightDsum = 0;
        }
    public void inputMatrix() {
        Scanner in = new Scanner(System.in);
        for(int i = 0; i < odr; i++) {
            for(int j = 0; j < odr; j++) {
                System.out.println("Input the element:");
                Mat[i][j] = in.nextInt();
                }
            }
        }   
    public void displayMatrix() {
        flag = true;
        System.out.println("ORIGINAL MATRIX:");
        for(int i = 0; i < odr; i++) {
            for(int j = 0; j < odr; j++) {
                if( Mat[i][j] != Mat[j][i])
                    flag = false;
                if(j == i)
                    leftDsum += Mat[i][j];
                if( i+j == odr-1)
                    rightDsum += Mat[i][j];       
                System.out.print(Mat[i][j]+"  ");
                }
            System.out.println();
            }
        if( flag == true )
            System.out.println("THE GIVEN MATRIX IS SYMMETRIC");
        else
            System.out.println("THE GIVEN MATRIX IS NOT SYMMETRIC");   
        }   
    public void diagonalSum() {
        System.out.println();
        System.out.println("The sum of the left diagonal: "+leftDsum);
        System.out.println();
        System.out.println("The sum of the right diagonal: "+rightDsum);
        System.out.println();   
        }
    private int odr;   
    private int[][] Mat;
    private boolean flag;
    private int leftDsum;
    private int rightDsum;
    }