Upload files to "OOP/Java/Lab/Week10"

This commit is contained in:
Aadit Agrawal 2024-10-14 02:40:51 +05:30
parent 22f306573d
commit 0b8cfc509f
5 changed files with 162 additions and 0 deletions

View file

@ -0,0 +1,29 @@
import java.util.*;
class InvalidMatrixException extends Exception
{
public String toString()
{
return "InvalidMatrixException:this is an Invalid Matrix";
}
}
public class Valid_matrix {
public static void main(String[] args) {
int row,col;
Scanner in=new Scanner(System.in);
System.out.println("Enter the number of rows and columns");
row=in.nextInt();
col=in.nextInt();
try
{
if(row!=col)
{
throw new InvalidMatrixException();
}
System.out.println("This is a valid matrix");
}
catch(InvalidMatrixException e)
{
System.out.println(e.toString());
}
}
}