Help Java

Sharky Forums


Results 1 to 2 of 2

Thread: Help Java

  1. #1
    Reef Shark
    Join Date
    Sep 2001
    Location
    Canada
    Posts
    268

    Help Java

    Im using JCreator. and im getting an error when i compile this.

    public static char computeLetterGrade(float percentGrade) {
    if (percentGrade < 50) {
    return 'F';
    else if ((percentGrade >= 50) && (percentGrade < 60))
    return 'D';
    else if ((percentGrade >= 60) && (percentGrade < 70))
    return 'C';
    else if ((percentGrade >= 70) && (percentGrade < 80))
    return 'B';
    else
    return 'A';
    }
    }

    The error is:

    'class' or 'interface' expected
    public static char computeLetterGrade(float percentGrade) {
    ^

    What should be changed?

  2. #2
    NullPointerException rock's Avatar
    Join Date
    Sep 2000
    Location
    York, PA
    Posts
    6,203

    Re: Help Java

    What you have there is just a method. You either need to convert it to a class or write a class around it. Any file Blah.java must contain a public class Blah.

    Open Source is free like a puppy is free.

    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.

    Understanding Evolution

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •