-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
53 lines (50 loc) · 1.77 KB
/
Main.java
File metadata and controls
53 lines (50 loc) · 1.77 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
44
45
46
47
48
49
50
51
52
53
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~
--||author : codechaser||--
~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
package java_labs.lab_5.problem_2;
import java.util.*;
import java.io.*;
import java_labs.lab_5.problem_2.package1.*;
public class Main {
public static void start() {
Scanner input = new Scanner(System.in);
System.out.println("\n\n---------------------------");
System.out.println(" P R O B L E M 2");
System.out.println("---------------------------\n");
System.out.println("Enter the size of the list :\n");
int size = input.nextInt();
System.out.println("\nEnter the elements of the list :\n");
Vector<Integer> list = new Vector<Integer>(size);
for(int i = 0; i < size; i++) {
int inp = input.nextInt();
list.add(inp);
}
System.out.println("\n---------------------------\n");
double ans = Sum.sum(list);
int k;
try {
k = Minimum.minimum(list);
if(k == 0) throw new Exception("Cannot divide by zero. Minimum element of the list cannot be zero.\n");
} catch (Exception e) {
System.out.println(e);
System.out.println("\n---------------------------\n");
return;
}
ans /= k;
System.out.println("The required answer is : " + ans);
System.out.println("\n---------------------------\n");
}
public static void main(String[] Args) {
start();
return;
}
}
/*
|---------------------------------------------------|
||| https://codeforces.com/profile/codechaser |||
||| https://www.codechef.com/users/codechaser |||
||| https://github.com/code-chaser |||
|---------------------------------------------------|
*/