Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   JAVA code (http://www.programmingforums.org/showthread.php?t=15479)

A.K.Al Shamsi Mar 25th, 2008 12:20 PM

JAVA code
 
hi.... how are you guys???
i am programming and we just start taking Java this semester so if anyone could help by checking it, i will be grateful

i was practicing and for some reasons the programme doesn't work completely.... i don't have error syntax...

here is the code:

:

import javax.swing.*;
import java.lang.String;

public class Grade{
    public static void main(String args[]){
       
        int grade=0, cat;
        String g, a,b,c,d,e;
       
        cat= grade/10;
       
        g=JOptionPane.showInputDialog("Enter your grade");
       
        grade=Integer.parseInt(g);
       
        switch(cat){
            case 1:
             
                JOptionPane.showMessageDialog(null,"Prefect score");
            break;
           
            case 2:
           
                JOptionPane.showMessageDialog(null,"well done");
            break;
     
            case 3:
             
                JOptionPane.showMessageDialog(null,"Above the averageg");
                break;
           
            case 4:
               
                JOptionPane.showMessageDialog(null,"Average");
                break;
               
            case 5:
             
                JOptionPane.showMessageDialog(null,"Below the average... Shame on you");
                break;
               
           
           
        }
       
       
       
    }
}


Ooble Mar 25th, 2008 1:57 PM

Re: JAVA code
 
Remember that instructions are executed in the order you see them. If you put instruction B before instruction A, chances are it'll be run first.

With this in mind, can you figure out why the following code is in the wrong place?
:

        cat= grade/10;

A.K.Al Shamsi Mar 25th, 2008 9:23 PM

Re: JAVA code
 
thanks i figure it out.... it should be after the input dialog..... thanks alot


All times are GMT -5. The time now is 12:56 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC