1 package strings; gm 3 import javax. swing.30ptionPane; gs 5 public class DateV
ID: 3875723 • Letter: 1
Question
1 package strings; gm 3 import javax. swing.30ptionPane; gs 5 public class DateValidation 4 6 public static void main (Stringl] ar) rc 7 str 8String date; 9 int m,d,y,loc1,loc2; boolean valid = true; 12 13 14 15 16 17 18 19 2e I/user input date = JOptionPane.showInputDialog("Enter date m/d/y format"); 1/location of first slash loc! date . indexOf("/"); 10e2 = date . lastIndexOf("/"); I/get month, day and year m=Integer.parseInt(date.substring(8, lod)); d = Integer.parselnt(date.substring(10c1+1,1oe2)); 22 y Integer.parseInt (date.substring(loc2+1)); 23 24 25 26 if (m 3a) 34 35 if(valid) 36 37 else 38 39 40 30ptionPane.showMessageDialog(null,"Invalid date: "+ date); OptionPane.showMessageDialog(null, "Ininvalid date: " + date)Explanation / Answer
else if (d<29 )
return True
else
return False
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.