From c5969f3f0aa4ec0e8f419df1c887692959247474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1ndly=20Gerg=C5=91?= Date: Tue, 20 Oct 2020 10:58:14 +0300 Subject: [PATCH] chore: Lab01 --- Lab01/.classpath | 10 ++++++++++ Lab01/.project | 17 +++++++++++++++++ Lab01/src/lab01/Lab01.java | 20 ++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 Lab01/.classpath create mode 100644 Lab01/.project create mode 100644 Lab01/src/lab01/Lab01.java diff --git a/Lab01/.classpath b/Lab01/.classpath new file mode 100644 index 0000000..9af0373 --- /dev/null +++ b/Lab01/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Lab01/.project b/Lab01/.project new file mode 100644 index 0000000..4299593 --- /dev/null +++ b/Lab01/.project @@ -0,0 +1,17 @@ + + + Lab01 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Lab01/src/lab01/Lab01.java b/Lab01/src/lab01/Lab01.java new file mode 100644 index 0000000..6856148 --- /dev/null +++ b/Lab01/src/lab01/Lab01.java @@ -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)); + } + +}