-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram07.java
More file actions
31 lines (29 loc) · 931 Bytes
/
Copy pathProgram07.java
File metadata and controls
31 lines (29 loc) · 931 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
import javax.swing.*;
public class Program07 {
public static void sum(int vet[]){
int s = 0;
for(int i = 0; i < vet.length; i++){
s = s + vet[i];
}
JOptionPane.showMessageDialog(null, "The summary is " + s);
}
public static int product(int vet[]){
int prod = 1;
for(int i = 0; i < vet.length; i++){
prod = prod * vet[i];
}
return prod;
}
public static void main(String enter[]){
int p, vet[], n;
n = Integer.parseInt(JOptionPane.showInputDialog("Enter the length you want"));
vet = new int[n];
for(int i = 0; i < vet.length; i++){
vet[i] = Integer.parseInt(JOptionPane.showInputDialog("Enter a integer numbers to " + i));
}
sum(vet);
p = product(vet);
JOptionPane.showMessageDialog(null, "The product is " + p);
System.exit(0);
}
}