-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathOperation.java
More file actions
29 lines (27 loc) · 890 Bytes
/
MathOperation.java
File metadata and controls
29 lines (27 loc) · 890 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
import java.util.Scanner;
public class MathOperation {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int arr[] = new int[n];
try {
for (int i = 0; i < arr.length; i++) {
arr[i] = Integer.parseInt(args[i]);
}
int sum = 0;
double average = 0;
for (int i = 0; i < args.length; i++) {
sum += arr[i];
average = sum / arr.length;
}
System.out.println("Sum is :: " + sum);
System.out.println("Average is :: " + average);
}
catch (Exception obj){
System.out.println("Exception Handled");
}
}
}
//Arithmetic Exception
//Number Format Exception
//Array Index Out Of Bound Exception and so on.......