diff --git a/Week8/EclipseIDE/Assignment8/src/partC/CountNumbers.java b/Week8/EclipseIDE/Assignment8/src/partC/CountNumbers.java deleted file mode 100644 index 7ac646d..0000000 --- a/Week8/EclipseIDE/Assignment8/src/partC/CountNumbers.java +++ /dev/null @@ -1,32 +0,0 @@ -//This code is written by Siwat Sirichai -package partC; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Scanner; -public class CountNumbers { - - public static void main(String[] args) { - try { //Since java.io.File throws FileNotFoundException, a try-catch block is neccessary. - Scanner sc = new Scanner(new File("numbers.txt")); //This create a scanner with file "number.txt" as an input - int length = 0; //define array length initialy at zero - for(length = 0;sc.hasNextInt();length++)sc.nextInt(); //Use File Scanner to find the number of elements in the file - int[] int_array = new int[length]; //Create an array with length number of elements - sc = new Scanner(new File("numbers.txt")); //Send the Scanner's cursor to the top of the file - for(int i = 0;iv)count++;//This is called a for-each loop, it will loop for a.length iteration, - return count; - } - -}