adventofcode/2022/day01/CalorieCount.java
Fennel Kora 77cb70fb39 Changed from Rust to Java because I'm a scrub
On branch master
 Changes to be committed:
	new file:   2022/day01/CalorieCount.java
	deleted:    2022/day01/calorie_count.rs
2022-12-02 11:27:38 -05:00

27 lines
No EOL
927 B
Java

import java.nio.file.Paths;
import java.io.IOException;
import java.util.Scanner;
public class CalorieCount {
public static void main(String[] args) {
try (Scanner inputReader = new Scanner(Paths.get("input.txt"))) {
int maxCals = 0;
while (inputReader.hasNext()) {
int currentCals = 0;
String inLine = new String();
do {
inLine = inputReader.nextLine();
if (!inLine.isEmpty()) {
currentCals += Integer.parseInt(inLine);
}
} while (!inLine.isEmpty());
if (currentCals > maxCals) {maxCals = currentCals;}
}
System.out.printf("The large calories carried is: %d", maxCals);
} catch (IOException e) {
System.out.println("IOException");
e.printStackTrace();
}
}
}