Results 1 to 4 of 4
  1. #1

    Default unsay kulang and mali ani nga code(Exception java).pls help


    unsa kulang ani nga code and sayop or dapat nako i add? pls. help me..

    ang output ani niya kay.. pa input niya ang user og time nga 12:00 format (sample sa input: 12:00) then i trap niya ang mga error. then and output kay (ex. Time is 00:00) then naa pod problem sa condisyon sa akong main...i.error niya. wa ko kasabot ngano iya ierror.. thnx

    mao ni akong code mga boss..

    class TimeFormatException extends Exception{

    public TimeFormatException(String msg){

    super(msg);

    }
    }
    import javax.swing.*;

    public class testTimeFormatException{

    public static void main(String[] args){

    int hour = 0 ;
    int minutes = 0 ;
    String inputTime = " ";
    String outputTime = " ";



    try
    {
    inputTime = JOptionPane.showInputDialog(null,"Enter hour","00");
    hour = Integer.parseInt(inputTime);

    inputTime = JOptionPane.showInputDialog(null,"Enter hour","00");
    minutes = Integer.parseInt(inputTime);


    if(hour > 12 && minutes >59 || hour < 01 && minutes <00 );

    throw (new TimeFormatException("Invalid time"));

    }

    catch(NumberFormatException e){

    JOptionPane.showMessageDialog(null,"Non - numeric time: " + inputTime);

    }

    catch(TimeFormatException e){

    JOptionPane.showMessageDialog(null,"Invalid time: " + inputTime);

    }
    JOptionPane.showMessageDialog(null,"Time is " + hour + ":" + minutes);
    }
    }

  2. #2

    Default Re: unsay kulang and mali ani nga code(Exception java).pls help

    Quote Originally Posted by ngitob View Post
    unsa kulang ani nga code and sayop or dapat nako i add? pls. help me..

    ang output ani niya kay.. pa input niya ang user og time nga 12:00 format (sample sa input: 12:00) then i trap niya ang mga error. then and output kay (ex. Time is 00:00) then naa pod problem sa condisyon sa akong main...i.error niya. wa ko kasabot ngano iya ierror.. thnx

    mao ni akong code mga boss..

    class TimeFormatException extends Exception{

    public TimeFormatException(String msg){

    super(msg);

    }
    }
    import javax.swing.*;

    public class testTimeFormatException{

    public static void main(String[] args){

    int hour = 0 ;
    int minutes = 0 ;
    String inputTime = " ";
    String outputTime = " ";



    try
    {
    inputTime = JOptionPane.showInputDialog(null,"Enter hour","00");
    hour = Integer.parseInt(inputTime);

    inputTime = JOptionPane.showInputDialog(null,"Enter hour","00");
    minutes = Integer.parseInt(inputTime);


    if(hour > 12 && minutes >59 || hour < 01 && minutes <00 );

    throw (new TimeFormatException("Invalid time"));

    }

    catch(NumberFormatException e){

    JOptionPane.showMessageDialog(null,"Non - numeric time: " + inputTime);

    }

    catch(TimeFormatException e){

    JOptionPane.showMessageDialog(null,"Invalid time: " + inputTime);

    }
    JOptionPane.showMessageDialog(null,"Time is " + hour + ":" + minutes);
    }
    }
    Move the
    Code:
     import javax.swing.*
    to the very beginning of the file.

  3. #3

    Default Re: unsay kulang and mali ani nga code(Exception java).pls help

    since testTimeFormatException is an inner class and contains a static members e.g static main(), so make your testTimeFormatException class static.

  4. #4

    Default Re: unsay kulang and mali ani nga code(Exception java).pls help

    ok thnx...mga boss

  5.    Advertisement

Similar Threads

 
  1. Replies: 17
    Last Post: 01-24-2012, 11:53 AM
  2. Unsay tan-aw ninyo ani nga youtube video?
    By yodawg in forum General Discussions
    Replies: 4
    Last Post: 01-21-2012, 01:33 PM
  3. Unsay maka sulti ninyo ani nga panag UYAB...
    By kyzlion in forum "Love is..."
    Replies: 6
    Last Post: 08-17-2011, 11:11 AM
  4. Unsay cause and effect ani? Error-code-ssl-error-bad-mac-read
    By goldfinger in forum Networking & Internet
    Replies: 7
    Last Post: 02-24-2011, 09:46 PM
  5. Unsay Kaila inan sa ani nga card?
    By circles122345 in forum Websites & Multimedia
    Replies: 4
    Last Post: 11-29-2006, 03:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top