I've created a method that requests input for a grading and would like 0 to be a valid input result. But my code doesn't allow it? Can anyone help?

public int getValidModuleMark3 ()

{   Scanner input = new Scanner(System.in);

    int mark;
    System.out.println ("Enter number of compensentable failed credits in range 0 to 180");
    mark=input.nextInt();
     while (mark < 180) {

    System.out.println("Invalid mark !");

    System.out.println ("Enter number of compensentable failed credits in range 0 to 180");
          mark=input.nextInt();
        }
     return mark;   

  }

Your code doesn't allow for any of the correct values except 180. If you want values inside that range you have to think about excluding the ones outside that range. something like this,
while (mark < 0 || mark > 180), wil allow all the marks from 0 to 180.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.