Fixed bug that caused error when EOF reached
Changes to be committed: modified: 2022/day01/CalorieCount.java
This commit is contained in:
parent
77cb70fb39
commit
900ee5e2d1
1 changed files with 8 additions and 4 deletions
|
@ -13,12 +13,16 @@ public class CalorieCount {
|
||||||
inLine = inputReader.nextLine();
|
inLine = inputReader.nextLine();
|
||||||
if (!inLine.isEmpty()) {
|
if (!inLine.isEmpty()) {
|
||||||
currentCals += Integer.parseInt(inLine);
|
currentCals += Integer.parseInt(inLine);
|
||||||
|
System.out.printf("Current elf total is %d%n", currentCals);
|
||||||
}
|
}
|
||||||
} while (!inLine.isEmpty());
|
} while (!inLine.isEmpty() && inputReader.hasNext());
|
||||||
|
|
||||||
if (currentCals > maxCals) {maxCals = currentCals;}
|
if (currentCals > maxCals) {
|
||||||
|
maxCals = currentCals;
|
||||||
|
System.out.printf("New Max Cals: %d%n", maxCals);
|
||||||
}
|
}
|
||||||
System.out.printf("The large calories carried is: %d", maxCals);
|
}
|
||||||
|
System.out.printf("The large calories carried is: %d%n", maxCals);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("IOException");
|
System.out.println("IOException");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in a new issue