-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem5.java
More file actions
33 lines (23 loc) · 892 Bytes
/
problem5.java
File metadata and controls
33 lines (23 loc) · 892 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
package sheetArrays;
import java.util.Scanner;
public class problem5 {
public static void main(String[] args) {
System.out.println("Enter size of integer array : ");
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] arr = new int[n];
System.out.println("Enter value : ");
arr[0] = in.nextInt();
int lastLargest = arr[0], largest = arr[0];
for (int i = 1; i < n; i++) {
System.out.println("Enter value : ");
arr[i] = in.nextInt();
if (arr[i] > largest) {
lastLargest=largest;
largest = arr[i];
}
}
int product=lastLargest*largest;
System.out.println("Pair is ("+lastLargest+","+largest+"), Maximum Product:"+product);
}
}