chore: Lab01

This commit is contained in:
Fándly Gergő
2020-10-20 10:58:14 +03:00
parent ddad6af608
commit c5969f3f0a
3 changed files with 47 additions and 0 deletions

View 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));
}
}