-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassign1.java
More file actions
54 lines (45 loc) · 835 Bytes
/
Copy pathassign1.java
File metadata and controls
54 lines (45 loc) · 835 Bytes
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.*;
class assign1
{
public static void main(String [] args)
{
int rowsum=0;
int colsum=0;
int[][] sales=new int[5][5];
Scanner sc=new Scanner(System.in);
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
sales[i][j]=sc.nextInt();
}
}
System.out.println(" P1 P2 P3 P4 total");
for(int i=0;i<sales.length;i++)
{
System.out.print("S"+(i+1));
for(int j=0;j<sales.length;j++)
{
System.out.print(" "+sales[i][j]+" ");
}
System.out.print("\n\n");
}
for(int i=0;i<4;i++)
{
rowsum=0;
for(int j=0;j<4;j++)
{
rowsum+=sales[i][j];
}
System.out.println(" "+rowsum);
}
for(int j=0;j<4;j++)
{
//for(int i=0;i<4;i++)
//{
colsum+=sales[i][j];
//}
System.out.println(" "+colsum);
}
}
}