import java.io.*;
abstract class matrix
{
int a[]=new int[10];
abstract void cal();
}
class derived extends matrix
{
int i,sum=0,n;
public void get()
{
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("Enter matrix size");
n=Integer.parseInt(cin.readLine());
System.out.println("Enter the first matrix");
for(i=0;i<n;i++)
{
a[i]=Integer.parseInt(cin.readLine());
}
}
catch(Exception e)
{
System.out.println("wrong data");
}
}
public void cal()
{
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
System.out.println("the sum of array element is= "+sum);
}
}
class abs_arr_add
{
public static void main(String args[])
{
derived d=new derived();
d.get();
d.cal();
}
}
abstract class matrix
{
int a[]=new int[10];
abstract void cal();
}
class derived extends matrix
{
int i,sum=0,n;
public void get()
{
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("Enter matrix size");
n=Integer.parseInt(cin.readLine());
System.out.println("Enter the first matrix");
for(i=0;i<n;i++)
{
a[i]=Integer.parseInt(cin.readLine());
}
}
catch(Exception e)
{
System.out.println("wrong data");
}
}
public void cal()
{
for(i=0;i<n;i++)
{
sum=sum+a[i];
}
System.out.println("the sum of array element is= "+sum);
}
}
class abs_arr_add
{
public static void main(String args[])
{
derived d=new derived();
d.get();
d.cal();
}
}
No comments:
Post a Comment