How to make it work?
i have a task to count the longest streak of ascending numbers: 1 2 3 4 -> streak of 4 1 2 3 4 2 3 4 5 6 -> longest streak is 5 (2 3 4 5 6) so i have one problem, the problem is that when i "break" the streak with a lower number then the one before, and then starting to build a larger streak - it wont count in the streak the first number that "broke" the last streak - cuz it just resets the streak... example: 1 2 3 4 5 4 5 6 7 8 9 -> outputs 5 instead of 6. (btw, the input will stop when entering 999 or -1) my code: import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter Percent:"); double percent = scan.nextDouble(); int streak = 0; int maxStreak = streak; double max = 0; while(percent != -1 && percent != 999){ if (percent > max){ max = percent; streak++; } if (percent < max){ streak = 0; max = 0; } if (streak > maxStreak){ maxStreak = streak; } System.out.println("Enter Percent:"); percent = scan.nextDouble(); } System.out.println("Longest Streak of days with high percentage: " + maxStreak); } }