diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/CircleWithChehckedException.html b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/CircleWithChehckedException.html
new file mode 100644
index 0000000..0540d10
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/CircleWithChehckedException.html
@@ -0,0 +1,74 @@
+
+
+
+CircleWithCheckedException.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/CircleWithCheckedException.java |
+
+
+
+
+
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+
+
+@author
+
+public class CircleWithCheckedException {
+ private double radius;
+
+ public CircleWithCheckedException() throws Exception
+ {
+ this(1.0);
+ }
+ public CircleWithCheckedException(double radius) throws Exception
+ {
+ if (radius < 0) {
+ throw new Exception("Radius cannot be negative.");
+ }
+ this.radius = radius;
+ }
+
+ public double getRadius() {
+ return radius;
+ }
+ public void setRadius(double radius) throws Exception {
+ if (radius < 0) {
+ throw new Exception("Radius cannot be negative.");
+ }
+ this.radius = radius;
+ }
+
+ @Override
+ public String toString() {
+ return "CircleWithCheckedException{" + "radius=" + radius + '}';
+ }
+ public static void main(String[] args) {
+ try {
+ System.out.println(new CircleWithCheckedException(5));
+ System.out.println(new CircleWithCheckedException(-5));
+ System.out.println(new CircleWithCheckedException(10));
+ } catch (Exception ex) {
+ System.err.println("an exception occured: " + ex.getMessage());
+ }
+
+ }
+}
+
+
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/Lab6Exceptions_CalebFontenot.html b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/Lab6Exceptions_CalebFontenot.html
new file mode 100644
index 0000000..1f9f6f1
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/Lab6Exceptions_CalebFontenot.html
@@ -0,0 +1,40 @@
+
+
+
+Lab6Exceptions_CalebFontenot.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/Lab6Exceptions_CalebFontenot.java |
+
+
+
+
+
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+
+
+@author
+
+public class Lab6Exceptions_CalebFontenot {
+
+ public static void main(String[] args) {
+ System.out.println("Hello World!");
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ProcessScoresInTextFile.html b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ProcessScoresInTextFile.html
new file mode 100644
index 0000000..993ed05
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ProcessScoresInTextFile.html
@@ -0,0 +1,73 @@
+
+
+
+ProcessScoresInTextFile.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ProcessScoresInTextFile.java |
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Scanner;
+
+
+
+@author
+
+public class ProcessScoresInTextFile {
+ public static void main(String[] args) throws Exception
+ {
+ File file = new File("scores.txt");
+
+
+ Scanner input = new Scanner(file);
+
+ ArrayList<String> nameAR = new ArrayList<>();
+ ArrayList<Integer> intAR = new ArrayList<>();
+
+
+ int iterate = 0;
+ int score;
+ while (input.hasNext()) {
+ iterate++;
+ String name = input.next();
+ score = input.nextInt();
+ nameAR.add(name);
+ intAR.add((Integer) score);
+ }
+ double average = 0;
+ for (int i = 0; i < intAR.size(); ++i) {
+ System.out.print(nameAR.get(i) + " ");
+ System.out.println(intAR.get(i));
+ average += intAR.get(i);
+ }
+ average = (average / intAR.size());
+ System.out.println("Average: " + average);
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ReadFileFromURL.html b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ReadFileFromURL.html
new file mode 100644
index 0000000..f83f3dd
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ReadFileFromURL.html
@@ -0,0 +1,73 @@
+
+
+
+ReadFileFromURL.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ReadFileFromURL.java |
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.util.Scanner;
+
+
+
+@author
+
+public class ReadFileFromURL {
+ public static void main(String[] args)
+ {
+ boolean continueLoop = false;
+ boolean exceptionThrown = false;
+ do {
+ System.out.print("Enter a URL: ");
+ String URLString = new Scanner(System.in).next();
+
+ try {
+ java.net.URL url = new java.net.URL(URLString);
+ int count = 0;
+ Scanner input = new Scanner(url.openStream());
+ while (input.hasNext()) {
+ String line = input.nextLine();
+ count += line.length();
+ }
+ System.out.println("The file size is " + count + " characters");
+ exceptionThrown = false;
+ } catch (java.net.MalformedURLException ex) {
+ System.out.println("Invalid URL");
+ exceptionThrown = true;
+ } catch (java.io.IOException ex) {
+ System.out.println("IO Errors");
+ }
+ if (exceptionThrown) {
+ continueLoop = true;
+ } else {
+ continueLoop = false;
+ }
+ } while (continueLoop);
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ReadFileFromWeb.html b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ReadFileFromWeb.html
new file mode 100644
index 0000000..da2b7ab
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ReadFileFromWeb.html
@@ -0,0 +1,61 @@
+
+
+
+ReadFileFromWeb.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ReadFileFromWeb.java |
+
+
+
+
+
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.util.Scanner;
+
+
+
+@author
+
+public class ReadFileFromWeb {
+ public static void main(String[] args) {
+ System.out.print("Enter a URL: ");
+ String URLString = new Scanner(System.in).next();
+ try {
+ java.net.URL url = new java.net.URL(URLString);
+ int count = 0;
+ String text ="";
+ Scanner input = new Scanner(url.openStream());
+ while (input.hasNext()) {
+ String line = input.nextLine();
+ count += line.length();
+ text += line;
+ }
+ System.out.println("The file size is " + count + " characters.");
+ System.out.println(text);
+ } catch (java.net.MalformedURLException ex) {
+ System.out.println("Invalid URL");
+ }
+ catch (java.io.IOException ex) {
+ System.out.println("IO Errors!");
+ }
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ReadFileFromWeb1.html b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ReadFileFromWeb1.html
new file mode 100644
index 0000000..f60d39c
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ReadFileFromWeb1.html
@@ -0,0 +1,80 @@
+
+
+
+ReadFileFromWeb1.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ReadFileFromWeb1.java |
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.util.Scanner;
+
+
+
+@author
+
+public class ReadFileFromWeb1 {
+ public static void main(String[] args) {
+ System.out.print("Enter a URL (defaults to \"https://calebfontenot.com\"): ");
+ String URLinput = new Scanner(System.in).nextLine();
+ String URLString;
+ if (URLinput.isEmpty()) {
+ URLString = "https://calebfontenot.com";
+ }
+ else {
+ URLString = URLinput;
+ }
+ try {
+ java.net.URL url = new java.net.URL(URLString);
+ int count = 0, divCount = 0, pCount = 0;
+ String text ="";
+ Scanner input = new Scanner(url.openStream());
+ while (input.hasNext()) {
+ String line = input.nextLine();
+ count += line.length();
+ text += line;
+ if (line.contains("<div")) {
+ divCount++;
+ }
+ if (line.contains("<p")) {
+ pCount++;
+ }
+
+ }
+ System.out.println("The file size is " + count + " characters.");
+ System.out.println("There are " + divCount + " <div> tags on this site.");
+ System.out.println("There are " + pCount + " <p> tags on this site.");
+ System.out.println(text);
+ } catch (java.net.MalformedURLException ex) {
+ System.out.println("Invalid URL");
+ }
+ catch (java.io.IOException ex) {
+ System.out.println("IO Errors!");
+ }
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/TestFileClass.html b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/TestFileClass.html
new file mode 100644
index 0000000..a720ab8
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/TestFileClass.html
@@ -0,0 +1,57 @@
+
+
+
+TestFileClass.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/TestFileClass.java |
+
+
+
+
+
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.util.Scanner;
+
+
+
+@author
+
+public class TestFileClass {
+ public static void main(String[] args) {
+ Scanner input = new Scanner(System.in);
+ System.out.print("Enter a file path or directory: ");
+ String filePath = input.nextLine();
+ testFile(filePath);
+ }
+ public static void testFile(String filePath) {
+ java.io.File file = new java.io.File(filePath);
+ System.out.println("Does it exist? " + file.exists());
+ System.out.println("The file has " + file.length() + " bytes.");
+ System.out.println("Can it be read? " + file.canRead());
+ System.out.println("Can it be written? " + file.canWrite());
+ System.out.println("Is it a directory? " + file.isDirectory());
+ System.out.println("Is it a file? " + file.isFile());
+ System.out.println("Is it absolute? " + file.isAbsolute());
+ System.out.println("Is it hidden? " + file.isHidden());
+ System.out.println("The absolute path to this file is " + file.getAbsolutePath());
+ System.out.println("Last modified on " + new java.util.Date(file.lastModified()));
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ToDecimal.html b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ToDecimal.html
new file mode 100644
index 0000000..ff98e27
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/ToDecimal.html
@@ -0,0 +1,68 @@
+
+
+
+ToDecimal.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ToDecimal.java |
+
+
+
+
+
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.util.Scanner;
+
+
+
+@author
+
+public class ToDecimal {
+ public static int hexToDecimal(String hex) {
+ int decimalValue =0;
+ for (int i = 0; i < hex.length(); ++i) {
+ char hexChar = hex.charAt(i);
+ decimalValue = decimalValue * 16 + hexCharToDecimal(hexChar);
+ }
+ return decimalValue;
+ }
+ public static int hexCharToDecimal(char ch) {
+ ch = Character.toUpperCase(ch);
+ if (ch >= 'A' && ch <= 'F') {
+ return 10 + ch - 'A';
+ } else if (ch >= '0' && ch <= '9'){
+ return ch - '0';
+ } else {
+ throw new NumberFormatException("Invalid hex character");
+ }
+ }
+ public static void main(String[] args) {
+ Scanner input = new Scanner(System.in);
+ System.out.print("Enter a hex number or q/Q to quit: ");
+ String hex = input.nextLine();
+ while ("q".equals(hex.toLowerCase()) == false) {
+ System.out.println("The decimal value for hex number " + hex + " is " + hexToDecimal(hex.toUpperCase()));
+ System.out.print("Emter a hex number: ");
+ hex = input.nextLine();
+ }
+
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/Triangle.html b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/Triangle.html
new file mode 100644
index 0000000..1e2a1e3
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/Triangle.html
@@ -0,0 +1,75 @@
+
+
+
+Triangle.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/Triangle.java |
+
+
+
+
+
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.util.Scanner;
+
+
+
+@author
+
+public class Triangle implements Geo{
+ private double side1 = 1.0, side2 = 1.0, side3 = 1.0;
+
+ public Triangle(double side1, double side2, double side3) {
+ this.side1 = side1;
+ this.side2 = side2;
+ this.side3 = side3;
+ }
+
+ @Override
+ public double getArea() {
+ double s = (side1 + side2 + side3) / 2;
+ return Math.sqrt(s * (s - side1) * (s - side2) * (s - side3));
+ }
+ @Override
+ public double getPerimeter() {
+ return side1 + side2 + side3;
+ }
+ @Override
+ public String toString() {
+ return "Triangle: side1 = " + side1 + " side2 = " + side2 + " side3 = " + side3;
+ }
+ public static void main(String[] args) {
+ Scanner input = new Scanner(System.in);
+ System.out.println("Enter the three sides: ");
+ double side1 = input.nextDouble();
+ double side2 = input.nextDouble();
+ double side3 = input.nextDouble();
+ Triangle triangle = new Triangle(side1, side2, side3);
+ System.out.println("The area is " + triangle.getArea());
+ System.out.println("The perimeter is " + triangle.getPerimeter());
+ System.out.println(triangle);
+ }
+}
+interface Geo {
+ double getArea();
+ public double getPerimeter();
+}
+
+
+
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/WriteReadData.html b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/WriteReadData.html
new file mode 100644
index 0000000..d3cee87
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/WriteReadData.html
@@ -0,0 +1,66 @@
+
+
+
+WriteReadData.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/WriteReadData.java |
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Scanner;
+
+
+
+@author
+
+public class WriteReadData {
+ public static void main(String[] args) throws Exception
+ {
+ File file = new File("rw.txt");
+ int randInt;
+ if (!file.exists()) {
+ System.out.println("File does not exist! Creating it...");
+ try (PrintWriter output = new PrintWriter(file);) {
+ for (int i = 0; i < 100; ++i) {
+ randInt = (int) (Math.random() * 100);
+ System.out.println("Writing " + randInt + " to file...");
+ output.write(Integer.toString(randInt) + "\n");
+ }
+ } catch (Exception ex) {
+ System.out.println(ex);
+ }
+ }
+ Scanner input = new Scanner(file);
+ System.out.println("Reading file contents:");
+ while (input.hasNext()) {
+ System.out.println(input.next());
+ }
+ }
+}
+
+
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/WriteWithAutoClose.html b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/WriteWithAutoClose.html
new file mode 100644
index 0000000..2e4dfbb
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/WriteWithAutoClose.html
@@ -0,0 +1,61 @@
+
+
+
+WriteWithAutoClose.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/WriteWithAutoClose.java |
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.io.IOException;
+
+
+
+@author
+
+public class WriteWithAutoClose {
+ public static void main(String[] args) throws IOException
+ {
+ java.io.File file = new java.io.File("scores.txt");
+ if (file.exists()) {
+ System.out.println("File already exists!");
+ System.exit(0);
+ }
+
+
+
+ try (java.io.PrintWriter output = new java.io.PrintWriter(file);) {
+
+ output.print("John T Smith ");
+ output.println(90);
+ output.print("Eric K Jones ");
+ output.println(85);
+ }
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/WriteWithAutoClose2.html b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/WriteWithAutoClose2.html
new file mode 100644
index 0000000..e6c7099
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/Printed HTMLs/WriteWithAutoClose2.html
@@ -0,0 +1,63 @@
+
+
+
+WriteWithAutoClose2.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/WriteWithAutoClose2.java |
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+
+
+
+
+@author
+
+public class WriteWithAutoClose2 {
+ public static void main(String[] args) {
+ try {
+ java.io.File file = new java.io.File("scores.txt");
+ if (file.exists()) {
+ System.out.println("File already exists!");
+ System.exit(0);
+ }
+
+
+ try (java.io.PrintWriter output = new java.io.PrintWriter(file);) {
+
+ output.print("John T Smith ");
+ output.println(90);
+ output.print("Eric K Jones ");
+ output.println(85);
+ }
+ } catch (Exception ex) {
+ System.err.println("Cought exception: " + ex);
+ }
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/rw.txt b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/rw.txt
new file mode 100644
index 0000000..c810916
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/rw.txt
@@ -0,0 +1,100 @@
+66
+31
+93
+98
+45
+64
+73
+43
+97
+21
+98
+20
+18
+87
+91
+43
+30
+71
+15
+14
+53
+4
+81
+18
+76
+22
+88
+89
+76
+51
+94
+56
+64
+72
+96
+87
+43
+66
+61
+46
+46
+44
+32
+26
+90
+97
+97
+75
+97
+11
+95
+55
+9
+95
+17
+52
+19
+64
+31
+66
+62
+15
+77
+28
+73
+55
+34
+51
+72
+51
+88
+14
+98
+45
+0
+97
+66
+78
+94
+95
+5
+54
+92
+63
+69
+72
+91
+94
+43
+79
+56
+75
+54
+26
+37
+49
+77
+40
+6
+28
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/scores.txt b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/scores.txt
index a225378..108d307 100644
--- a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/scores.txt
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/scores.txt
@@ -1,2 +1,4 @@
-John T Smith 90
-Eric K Jones 85
+Caleb 90
+Hailey 85
+Davin 100
+Tyler 95
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ProcessScoresInTextFile.java b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ProcessScoresInTextFile.java
new file mode 100644
index 0000000..b555ed5
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ProcessScoresInTextFile.java
@@ -0,0 +1,45 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class ProcessScoresInTextFile {
+ public static void main(String[] args) throws Exception
+ {
+ File file = new File("scores.txt");
+
+ // Create a scanner for the file
+ Scanner input = new Scanner(file);
+
+ ArrayList nameAR = new ArrayList<>();
+ ArrayList intAR = new ArrayList<>();
+
+ // Read data from file
+ int iterate = 0;
+ int score;
+ while (input.hasNext()) {
+ iterate++;
+ String name = input.next();
+ score = input.nextInt();
+ nameAR.add(name);
+ intAR.add((Integer) score);
+ }
+ double average = 0;
+ for (int i = 0; i < intAR.size(); ++i) {
+ System.out.print(nameAR.get(i) + " ");
+ System.out.println(intAR.get(i));
+ average += intAR.get(i);
+ }
+ average = (average / intAR.size());
+ System.out.println("Average: " + average);
+ }
+}
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ReadFileFromURL.java b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ReadFileFromURL.java
new file mode 100644
index 0000000..380683c
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ReadFileFromURL.java
@@ -0,0 +1,45 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class ReadFileFromURL {
+ public static void main(String[] args)
+ {
+ boolean continueLoop = false;
+ boolean exceptionThrown = false;
+ do {
+ System.out.print("Enter a URL: ");
+ String URLString = new Scanner(System.in).next();
+
+ try {
+ java.net.URL url = new java.net.URL(URLString);
+ int count = 0;
+ Scanner input = new Scanner(url.openStream());
+ while (input.hasNext()) {
+ String line = input.nextLine();
+ count += line.length();
+ }
+ System.out.println("The file size is " + count + " characters");
+ exceptionThrown = false;
+ } catch (java.net.MalformedURLException ex) {
+ System.out.println("Invalid URL");
+ exceptionThrown = true;
+ } catch (java.io.IOException ex) {
+ System.out.println("IO Errors");
+ }
+ if (exceptionThrown) {
+ continueLoop = true;
+ } else {
+ continueLoop = false;
+ }
+ } while (continueLoop);
+ }
+}
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ReadFileFromWeb1.java b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ReadFileFromWeb1.java
new file mode 100644
index 0000000..54cd377
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/ReadFileFromWeb1.java
@@ -0,0 +1,52 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class ReadFileFromWeb1 {
+ public static void main(String[] args) {
+ System.out.print("Enter a URL (defaults to \"https://calebfontenot.com\"): ");
+ String URLinput = new Scanner(System.in).nextLine();
+ String URLString;
+ if (URLinput.isEmpty()) {
+ URLString = "https://calebfontenot.com";
+ }
+ else {
+ URLString = URLinput;
+ }
+ try {
+ java.net.URL url = new java.net.URL(URLString);
+ int count = 0, divCount = 0, pCount = 0;
+ String text ="";
+ Scanner input = new Scanner(url.openStream());
+ while (input.hasNext()) {
+ String line = input.nextLine();
+ count += line.length();
+ text += line;
+ if (line.contains(" tags on this site.");
+ System.out.println("There are " + pCount + "
tags on this site.");
+ System.out.println(text);
+ } catch (java.net.MalformedURLException ex) {
+ System.out.println("Invalid URL");
+ }
+ catch (java.io.IOException ex) {
+ System.out.println("IO Errors!");
+ }
+ }
+}
diff --git a/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/WriteReadData.java b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/WriteReadData.java
new file mode 100644
index 0000000..69a94fd
--- /dev/null
+++ b/Semester 2/Assignments/lab6-Exceptions_CalebFontenot/src/main/java/com/mycompany/lab6/exceptions_calebfontenot/WriteReadData.java
@@ -0,0 +1,38 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.mycompany.lab6.exceptions_calebfontenot;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class WriteReadData {
+ public static void main(String[] args) throws Exception
+ {
+ File file = new File("rw.txt");
+ int randInt;
+ if (!file.exists()) {
+ System.out.println("File does not exist! Creating it...");
+ try (PrintWriter output = new PrintWriter(file);) {
+ for (int i = 0; i < 100; ++i) {
+ randInt = (int) (Math.random() * 100);
+ System.out.println("Writing " + randInt + " to file...");
+ output.write(Integer.toString(randInt) + "\n");
+ }
+ } catch (Exception ex) {
+ System.out.println(ex);
+ }
+ }
+ Scanner input = new Scanner(file);
+ System.out.println("Reading file contents:");
+ while (input.hasNext()) {
+ System.out.println(input.next());
+ }
+ }
+}
\ No newline at end of file
diff --git a/Semester 2/ZIPs/lab6-Exceptions_CalebFontenot.zip b/Semester 2/ZIPs/lab6-Exceptions_CalebFontenot.zip
new file mode 100644
index 0000000..fa3b8e8
Binary files /dev/null and b/Semester 2/ZIPs/lab6-Exceptions_CalebFontenot.zip differ