chore: Lab01
This commit is contained in:
parent
ddad6af608
commit
c5969f3f0a
10
Lab01/.classpath
Normal file
10
Lab01/.classpath
Normal 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
17
Lab01/.project
Normal 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>
|
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));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user