Upload files to "OOP/Java/Lab/Week10"
This commit is contained in:
parent
22f306573d
commit
0b8cfc509f
5 changed files with 162 additions and 0 deletions
29
OOP/Java/Lab/Week10/Valid_matrix.java
Normal file
29
OOP/Java/Lab/Week10/Valid_matrix.java
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue