```
package javahistogram;

import java.util.Scanner;

public class JavaHistogram {

    public static void main(String[] args) {
        int sum = 0;
        int count = 0;
        int mark = 0;
        int largest = 0, smallest = 0;
        int rangeOne = 0, rangeTwo = 0, rangeThree = 0, rangeFour = 0;

        System.out.println("Enter marks, -1 to finish: ");
        Scanner in = new Scanner(System.in);

// Process data until the sentinel is entered
        if (in.hasNextInt()) {
            {

                while (mark != -1) {
                    mark = in.nextInt();

                    if (mark < -1 || mark > 100) {
                        System.out.println("Error: Enter Valid Input Type: Numbers from 0 - 100 for Marks. Or -1 to finish.");
                    } else if (mark != -1) {
                        sum = sum + mark;
                        count++;

                        if (count == 1) {
                            largest = mark;
                            smallest = mark;
                        } else {
                            if (mark > largest) {
                                largest = mark;
                            }
                            if (mark < smallest) {
                                smallest = mark;
                            }

                            if (mark >= 0 && mark <= 29) {
                                rangeOne++;
                            } else if (mark >= 30 && mark <= 39) {
                                rangeTwo++;
                            } else if (mark >= 40 && mark <= 69) {
                                rangeThree++;
                            } else if (mark >= 70 && mark <= 100) {
                                rangeFour++;
                            }

                        }
                    }
                }
            }
        } else {
            System.out.println("Error: Enter Valid Input Type: Integer");
        }

        for (int i = 1; i <= rangeOne; i++) {
            System.out.print("*");
        }

        for (int i = 1; i <= rangeTwo; i++) {
            System.out.println("*");
        }

        for (int i = 1; i <= rangeThree; i++) {
            System.out.println("*");
        }

        for (int i = 1; i <= rangeFour; i++) {
            System.out.println("*");
        }

        System.out.println(rangeOne + rangeTwo + rangeThree + rangeFour + " students in total");
        System.out.println("Largest mark is: " + largest);
        System.out.println("Smallest mark is: " + smallest);
        if (count > 0) {
            double average = sum / count;
            System.out.println("Average marks: " + average);
        } else {
            System.out.println("No data");
        }

        for (int i = 1; i <= rangeThree; i++) {
            System.out.println("Number of students passed " + i);
        }

    }
}

```

Having an error where my increment doesn't work properly.

For example, if I enter;

```
0, 0, 39, 39, 100

```

5 stars should be displayed.

However, at the moment only 4 stars will be displayed.

I am wondering where in my increment code am I going wrong?

With this, another problem is the format of my program.

For example, in this case of `0,0, 39, 39, 100`
It would display such as: 

```
0 - 29: **  
30 - 39: **  
70 - 100: *  

```

At the moment, it displays like

```
0 - 29: *  
0 - 29: *  
30 - 39: *  
30 - 39: *  
70 - 100: *  

```

Thanks. :)