chore: Lab01
This commit is contained in:
20
Lab01/src/lab01/Lab01.java
Normal file
20
Lab01/src/lab01/Lab01.java
Normal file
@ -0,0 +1,20 @@
|
||||
package lab01;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class Lab01 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int x = Integer.parseInt(JOptionPane.showInputDialog("Please enter the number of elements: "));
|
||||
|
||||
int sum = 0;
|
||||
for(int i = 0; i < x; i++) {
|
||||
int next = Integer.parseInt(JOptionPane.showInputDialog("Please enter a number: "));
|
||||
sum += next;
|
||||
}
|
||||
|
||||
float avg = sum/(float)x;
|
||||
JOptionPane.showMessageDialog(null, "The average is: " + String.valueOf(avg));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user