This commit is contained in:
2025-04-27 16:18:03 -05:00
parent a049cbf474
commit dc58e008b1
3 changed files with 40 additions and 8 deletions

View File

@@ -1,6 +1,30 @@
import java.io.*;
public class Main {
// Read contents of inFile, convert it all to uppercase, write to outFile
// Do line-by-line
public static void upperCaseFileConverter(String inFile, String outFile) {
try {
BufferedReader in = new BufferedReader(new FileReader(inFile));
BufferedWriter out = new BufferedWriter(new FileWriter(outFile));
String line;
while((line = in.readLine()) != null) {
out.write(line.toUpperCase());
//out.newLine();
}
}
catch (IOException e) {
System.out.println("File not found:");
System.out.println(e.getMessage());
}
}
public static void main(String[] args) {
@@ -13,7 +37,7 @@ public class Main {
testScoresArray[0] = new TestScores(new int[]{15, 24, 44, 30});
testScoresArray[1] = new TestScores(new int[]{69, 69, 55, 88, 92});
testScoresArray[2] = new TestScores(new int[]{82, 75, 89, 90, 0});
testScoresArray[3] = new TestScores(new int[]{72, 87, 92, 92, 94});
testScoresArray[3] = new TestScores(new int[]{72, 87, 92, 92, 96});
testScoresArray[4] = new TestScores(new int[]{100,100,100,100,100,100,100});
for(TestScores testScore : testScoresArray) {
@@ -29,7 +53,7 @@ public class Main {
System.out.println("Test Scores written to " + filename);
} catch (IOException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
// Deserialize objects from file
@@ -43,14 +67,21 @@ public class Main {
}
//TODO: FIX THESE CATCH CLAUSES
catch(IOException e){
e.printStackTrace();
System.out.println(e.getMessage());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
for(TestScores testScore : deserializedScores) {
System.out.println(testScore.getAverage());
try {
for (TestScores testScore : deserializedScores) {
System.out.println(testScore.getAverage());
}
}
catch(NullPointerException e){
System.out.println(e.getMessage());
}
upperCaseFileConverter("input.txt", "output.txt");
}
}

View File

@@ -1,11 +1,9 @@
import java.io.Serial;
import java.io.Serializable;
/**
* TestScores class will take an array of test Scores, and has a method to determine average
*/
public class TestScores implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
int[] scores; // The array of test scores

3
src/input.txt Normal file
View File

@@ -0,0 +1,3 @@
Hello World!
This is a file, that
Has words and stuff in it