Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8

Thread: basic java prog

  1. #1
    Member
    Join Date
    Feb 2002
    Posts
    80
    Member #
    25
    any suggestions for improvements??

    Code:
    import intro.*;
    
    public class CertificateCheck {
    
    	public static void main(String args[]) {
    		CertificateCheck obj = new CertificateCheck();
    	  	obj.advise();
    		System.exit(0);
    	}
    
    	public void advise() {
    		int number = 0;
    		int marks = 0;
    		int get = 0;
    		UserDialog ud = new UserDialog();
    
    		//ask user how many practicals
    		number = ud.getInt("how many pracs have u attended sucka?:");
    
    		if (number==0)
    				ud.showMessage("sorry biatch, u aint gettin **** coz u is a lazy *** fool!!");
    		else if (number > 3)
    				ud.showMessage("you talkin ****!! there aint more than 3 pracs!!");
    		else if (number < 0)
    				ud.showMessage("how can you have attended less than 0 pracs?! shut the **** up!");
    			else {
    				marks = ud.getInt("how many marks have u got sucka?:");
    					if (marks < 5)
    						ud.showMessage("sorry biatch u aint gettin **** coz u is a dumb *** fool!!");
    					else if (marks>=25)
    				
    						if (number==2)
    							ud.showMessage("u got cha certificate. dats dope");
    						else
    							ud.showMessage("you gotta come 2 tha last prac sucka!!");
    			
    					else
    						ud.showMessage("getcha *** to tha last prac and make up " + get + " marks biaaatch!");
    			}
    	}
    }

  2.  

  3. #2
    Junior Member
    Join Date
    Feb 2002
    Location
    Aberystwyth (Wales)
    Posts
    1
    Member #
    28
    erm you could javadoc it so that people could understand what it going on, also if there is input from the user, there could be errors from them entering a String as supposed to an Int so either you can throw the exception, e.g.

    Code:
    throw IOException;
    or you could handle the error and catch them in a try block

    this should make your code better

  4. #3
    Member
    Join Date
    Feb 2002
    Posts
    80
    Member #
    25
    Originally posted by zmerlinz
    erm you could javadoc it so that people could understand what it going on, also if there is input from the user, there could be errors from them entering a String as supposed to an Int so either you can throw the exception, e.g.

    Code:
    throw IOException;
    or you could handle the error and catch them in a try block

    this should make your code better
    ok dude...its me...remember im just gettin into this ...where would i put that code??

  5. #4
    Member
    Join Date
    Feb 2002
    Posts
    80
    Member #
    25
    oh and im gonna insert some pseudocode/comments l8r

  6. #5
    pix
    pix is offline
    Senior Member pix's Avatar
    Join Date
    Feb 2002
    Location
    With Chris
    Posts
    164
    Member #
    4
    Ok, I'm not sure if this will help, but here goes anyway...

    Any program which takes in input from a user can potentially cause errors e.g. user types an int rather than a string. Any errors of this kind will cause an IOException. If a program has an IOException then you have two options: ignore the exception, or handle the exception. If you choose to ignore the exception, then you just need to declare that the program can throw an exception e.g.

    Code:
    public static void main (String args[]) throws IOException
    If you choose to handle the exception then you can use try and catch blocks. Any code that can potentially throw an exception is placed within a try block. If an exception is thrown then the program will go to catch blocks, which will try to deal with the exception that has been thrown. You can have different catch blocks to deal with different exceptions. I wouldn't worry about dealing with exceptions though for now. If your code can throw an exception then just state that it can.
    I'm a nice innocent(ish) person

    Chris is very adorable :snog:

    And he has an adorable voice too

  7. #6
    Member
    Join Date
    Feb 2002
    Posts
    80
    Member #
    25
    Originally posted by pix
    Ok, I'm not sure if this will help, but here goes anyway...

    Any program which takes in input from a user can potentially cause errors e.g. user types an int rather than a string. Any errors of this kind will cause an IOException. If a program has an IOException then you have two options: ignore the exception, or handle the exception. If you choose to ignore the exception, then you just need to declare that the program can throw an exception e.g.

    Code:
    public static void main (String args[]) throws IOException
    If you choose to handle the exception then you can use try and catch blocks. Any code that can potentially throw an exception is placed within a try block. If an exception is thrown then the program will go to catch blocks, which will try to deal with the exception that has been thrown. You can have different catch blocks to deal with different exceptions. I wouldn't worry about dealing with exceptions though for now. If your code can throw an exception then just state that it can.
    ooo thanks nic, at least i understand it now

  8. #7
    pix
    pix is offline
    Senior Member pix's Avatar
    Join Date
    Feb 2002
    Location
    With Chris
    Posts
    164
    Member #
    4
    Really? Wow I managed to help someone for once
    I'm a nice innocent(ish) person

    Chris is very adorable :snog:

    And he has an adorable voice too

  9. #8
    Member
    Join Date
    Feb 2002
    Posts
    80
    Member #
    25
    Originally posted by pix
    Really? Wow I managed to help someone for once
    yeah

    were using a diff coding structure but that helped me to understand what the function is it was great thanks


Remove Ads

Posting Permissions

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

Search tags for this page

average cost for website

,

content changer online

,
fade in div after page load jquery
,

full sail university web design development reviews

,

iframe vs div

,

javascript line feed

,

javascript linefeed

,

list-style color

,

refresh a page at a specific time of day javascript

,
website age verification pages
Click on a term to search for related topics.
All times are GMT -6. The time now is 09:21 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com