Restore
This commit is contained in:
10
Labs/Lab2/Lab2Part1/Question9/.classpath
Normal file
10
Labs/Lab2/Lab2Part1/Question9/.classpath
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
17
Labs/Lab2/Lab2Part1/Question9/.project
Normal file
17
Labs/Lab2/Lab2Part1/Question9/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Question9</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>
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
BIN
Labs/Lab2/Lab2Part1/Question9/bin/GradesAverage.class
Normal file
BIN
Labs/Lab2/Lab2Part1/Question9/bin/GradesAverage.class
Normal file
Binary file not shown.
25
Labs/Lab2/Lab2Part1/Question9/src/GradesAverage.java
Normal file
25
Labs/Lab2/Lab2Part1/Question9/src/GradesAverage.java
Normal file
@@ -0,0 +1,25 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class GradesAverage {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner input = new Scanner(System.in);
|
||||
System.out.print("Enter the number of students: ");
|
||||
int numStudents = input.nextInt();
|
||||
int[] gradeStudent = new int[numStudents];
|
||||
float sum = 0;
|
||||
for(int i = 0; i < numStudents; i++) {
|
||||
int cnt = i + 1;
|
||||
System.out.print("Enter the grade for student " + cnt + " : ");
|
||||
gradeStudent[i] = input.nextInt();
|
||||
if(gradeStudent[i] < 0 || gradeStudent[i] > 100) {
|
||||
System.out.println("Invalid grade, try again...");
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
sum += gradeStudent[i];
|
||||
}
|
||||
System.out.println("The average is : " + sum/numStudents);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user