Results 1 to 2 of 2
- 10-13-2009, 04:43 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 6
- Rep Power
- 0
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. :/
- 10-13-2009, 07:31 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Similar Threads
-
E:\IT 215 Java Programming\GUI1.java:125: class, interface, or enum expected
By tlouvierre in forum New To JavaReplies: 1Last Post: 05-31-2009, 10:57 PM -
E:\IT 215 Java Programming\GUI1.java:125: class, interface, or enum expected
By tlouvierre in forum New To JavaReplies: 1Last Post: 05-31-2009, 02:17 PM -
E:\IT 215 Java Programming\Inventory.java:36: class, interface, or enum expected
By tlouvierre in forum Advanced JavaReplies: 16Last Post: 05-28-2009, 03:41 PM -
How to make a text field to accept numbers only?
By Robert_85 in forum Advanced JavaReplies: 15Last Post: 04-07-2009, 01:30 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks