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);
}
}