Welcome to Dream.In.Code
Become a Java Expert!

Join 150,386 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,128 people online right now. Registration is fast and FREE... Join Now!




switch comments

 
Reply to this topicStart new topic

switch comments, I can't get my comments to print in my JOptionPane

piejunkie
5 Feb, 2008 - 05:56 PM
Post #1

New D.I.C Head
*

Joined: 5 Feb, 2008
Posts: 2

I'm just learning about switchs, what's wrong with the JOptionPane part of this code, that it won't compile the comments from the previous swith. Thanks.

CODE


AverageScore = ((0.30*Test1)+(0.30*Test2)+(0.40*Final));
    
if ((AverageScore >= 90.000) && (AverageScore <= 100.000))
    {
    char LetterGrade = A;
    }
    
if ((AverageScore >= 80.000) && (AverageScore < 90.000))
    {
    char LetterGrade = B;
    }
    
if ((AverageScore >= 70.000) && (AverageScore < 80.000))
    {
    char LetterGrade = C;
    }
        
if ((AverageScore >= 60.000) && (AverageScore < 70.000))
    {
    char LetterGrade = D;
    }
        
if ((AverageScore < 60.000))
    {
    char LetterGrade = F;
    }

switch (LetterGrade) {
        
    case A:     comment = "GREAT!";    break;
    case B:    comment = "Good work."; break;
    case C:    comment = "Just so-so."; break;
    case D:    comment = "Better luck next time."; break;
    case F:    comment = "Better luck next time."; break;
    default: comment = "Call DJ, something has gone wrong.";
    }
            
        
JOptionPane.showMEssageDialog (null, "Test One Score: " + (Test1) "/n"
            + "Test Two Score: " + (Test2) "/n"
            + "Final Exam Score: " + (Final) "/n"
            + "Test Average: " + threeDigits(AverageScore) "/n"
            + comment, "Program 2 by DJ Garrison",
             "OOPS",JoptionPane.PLAIN_MESSAGE);

User is offlineProfile CardPM
+Quote Post

dontKnowJava
RE: Switch Comments
5 Feb, 2008 - 06:15 PM
Post #2

D.I.C Head
**

Joined: 29 Sep, 2007
Posts: 213


My Contributions
whats the error you get? i think some of your code is missing and a char value has to be in quotes char LetterGrade = 'F';
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 04:56PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month