Results 1 to 2 of 2
  1. #1
    Jessaurum is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default How do I make this if-else block accept the enum types in Java?

    public class Undergrad{
    ......
    public enum LetterGrade {
    EPURE, DPURE, DPLUS, CMINUS, CPURE, CPLUS, BMINUS, BPURE, BPLUS, AMINUS, APURE
    }
    .....
    public float getGPA(){
    int totalCredit = getTotalCredits();
    LetterGrade gradeValue;
    float totalGradeValue;
    float creditAmount;
    float totalGrades;
    int counter;
    while (counter < credits.size()){
    gradeValue = (LetterGrade)grades.get(counter);
    creditAmount = ((Integer)credits.get(counter)).floatVal
    if((LetterGrade)gradeValue == EPURE){
    totalGradeValue = 0;
    }
    .......else.....}

    This isn't my whole code, I put "...." where I left out stuff. An example of a compiler complaint is:
    Undergrad.java:72: cannot find symbol
    symbol : variable EPURE
    location: class Undergrad
    if((LetterGrade)gradeValue == EPURE){
    (error pointing to EPURE)

    I've tried everything, I don't know what I'm doing wrong. :/

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

Similar Threads

  1. Replies: 1
    Last Post: 05-31-2009, 10:57 PM
  2. Replies: 1
    Last Post: 05-31-2009, 02:17 PM
  3. Replies: 16
    Last Post: 05-28-2009, 03:41 PM
  4. How to make a text field to accept numbers only?
    By Robert_85 in forum Advanced Java
    Replies: 15
    Last Post: 04-07-2009, 01:30 PM

Posting Permissions

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