Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 25th, 2008, 12:20 PM   #1
A.K.Al Shamsi
Programmer
 
A.K.Al Shamsi's Avatar
 
Join Date: Mar 2008
Posts: 35
Rep Power: 0 A.K.Al Shamsi is on a distinguished road
Exclamation 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;
                
            
            
        }
        
        
        
    }
}
A.K.Al Shamsi is offline   Reply With Quote
Old Mar 25th, 2008, 1:57 PM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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;
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 25th, 2008, 9:23 PM   #3
A.K.Al Shamsi
Programmer
 
A.K.Al Shamsi's Avatar
 
Join Date: Mar 2008
Posts: 35
Rep Power: 0 A.K.Al Shamsi is on a distinguished road
Re: JAVA code

thanks i figure it out.... it should be after the input dialog..... thanks alot
A.K.Al Shamsi is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Incorporating javascript code into java application csrocker101 Java 1 Feb 11th, 2008 6:36 AM
Java code.....null pointer exceptions(again sorry) ELHEK Java 2 Oct 25th, 2006 1:56 PM
Java code to convert binary to decimal and hexadecimal to binary prince_haldir Java 1 Mar 7th, 2006 1:51 AM
Problem in my Java Code jch02140 Java 6 Aug 14th, 2005 3:08 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:35 AM.

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