-
Notifications
You must be signed in to change notification settings - Fork 0
/
double_dimension_adder.java
39 lines (39 loc) · 1.02 KB
/
double_dimension_adder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.Scanner;
public class double_dimension_adder extends qwertyuiop
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the no. of rows and column");
int a=sc.nextInt();
int b=sc.nextInt();
int c[][]=new int[a][b];
int d=0,e=0;
System.out.println("Enter the numbers:");
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
c[i][j]=sc.nextInt();
}
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
System.out.print(c[i][j]+" ");
System.out.println();
}
for(int i=0;i<a;i++)
{
d=0;
for(int j=0;j<b;j++)
d=d+c[i][j];
System.out.println("ROWS "+(i+1)+" :"+d);
}
for(int j=0;j<b;j++)
{
e=0;
for(int i=0;i<a;i++)
e=e+c[i][j];
System.out.println("COLUMNS "+(j+1)+" :"+e);
}
}
}