-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeek2b.java
More file actions
43 lines (42 loc) · 1.38 KB
/
Week2b.java
File metadata and controls
43 lines (42 loc) · 1.38 KB
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
import java.util.Scanner;
public class Week2b {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Number of Financial Years :");
int m =sc.nextInt();
System.out.println("Enter the Ids of the items :");
int n = sc.nextInt();
int[] years = new int[m];
int[] id = new int[n];
int[][] a = new int[m][n];
System.out.println("Enter the Financial Years :");
for(int i=0;i<m;i++){
id[i]=sc.nextInt();
}
System.out.println("Enter the Ids :");
for(int i=0;i<n;i++){
years[i]=sc.nextInt();
}
System.out.println("Enter the Demand of the Items :");
int k = Integer.MIN_VALUE;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
System.out.println("Enter demand of the item in the year "+id[i]+" with the item id "+years[j]);
a[i][j]=sc.nextInt();
if(k<a[i][j]){
k=a[i][j];
}
}
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(k==a[i][j]){
int t=id[i];
int b=years[j];
System.out.println("id = "+t+"year = "+b+"demand = "+k);
break;
}
}
}
}
}