• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

compile error

hello, im getting a error and dont understand what it means. It says missing return statement, any ideas.
this is the code that i get the error on:
//Method: getFinalExam
      private static int getFinalExam() throws IOException
      {
            int iReturn = -1;

            System.out.println("The Final exam is worth 100 total points");
            System.out.println("Please enter your fianl exam grade.");

            boolean bDone = false;
            while (!bDone)
            {

            int finalExam = Integer.parseInt(Keyboard.readLine());
            if ((finalExam >= 0) && (finalExam <= 100))
                  {
                        bDone = true;
                        iReturn = finalExam;
                  }
                  else
                  {
                        System.out.println("Enter a score from 1 - 100");
                  }
            return iReturn;
            }

      }
0
scJohn
Asked:
scJohn
  • 2
1 Solution
 
OBCTCommented:
return the iReturn outside of the while loop.
As far as the compiler is concerned, !isDone may never be true, therefore may not return.
0
 
OBCTCommented:
:-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now