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

10
Lab01/.classpath Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>

17
Lab01/.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Lab01</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

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