Answered step by step
Verified Expert Solution
Question
1 Approved Answer
hello! im trying to add an exception to my project . i noticed that if the user enters any number , it continues to print
hello! im trying to add an exception to my project . i noticed that if the user enters any number , it continues to print the right answers. i want to stop the program if they dont enter 01 01 2012 Or at least restart the program. i dont wsnt it to continue
Nangate Search Project Run Window Help Colymephism.jiva [1] CalenderDatejava x inport Java,util.Calendar; fnport java.util.Date; inport java.util. Scanner; public class calenderoate f poblic static vold main(string[] args) ( System;eurt-pefintla(7please enter Jabuary -1, 2012 using the follondng forat m-ddiyyoya=7); Scanner. se - nent scanner(Systed. in) f intdate=sc.Hextint() Colendar cal a Caltadar.getInatance( ) caliaddi(Calendar, gure, -2); cal.add ( Calendter. MoNTH, 2); csl. add ( Calender. rexR, 11) i pate d = chl. getTine( ) Systen, oukiprint ("The Mext Date Is x=d ) Colendar neincal = Calendar petina tance() nnicaliadd(calendanibure, -4); hiretali add (Calendne, Nevry, i) . bate c - nerical.getfine( ) Caleadar M(cal = Calendar,getinsmancet): Necitiadt(Calendari Mure, in) Deceloade (calendac. MWTH, 1) : necilidd (calendar, vaR, 11) : Nevigate Search Project fun Window Help cal,add (Calendar_MavT,,1); cal. add(Calendar. YEAR,-11): Date d- cel, petine(): Systen-aut.print (The. Next Date is f+d ): Calendar neveal - Calendar, gecinstance(); neweal. add (Calendae, a4te, 4 ) i neical. add (Calendar. MowTH, 1) ) newcal,add (Calendar. YEAR, - 11): Date C a nencal. getTine () F System.out, print( (liathe prior date is 1++c); Calendar accat = Calendar.geeInstance(); necal, bddt(Calender. MaTE, 1 ); necel, add (Calendar, WWNT, -1); fiecal-add(Calendar, Yees, -11); int in = neca , aAY OH WERK CalenderDate [Java Application] CilUserslpryor_a091331.p2lpoollpluginslorg.eclipse.justj.openjdk.hotsp Please enter January 1,2012 using the following format mm-dd-yyyy: 01.012011 The Next Date is :Mon Jan 0218:22:32 CST 2012 The prior date is : Sat Dec 3118:22:32 CST 2011 Monday =1, Tuesday =2, Wednesday =3, Thursday =4, Friday =5, Saturday =6, Sunday =7. The day of the week is : 7 notice how it continued to print oht to correct information when i put 01 01 2011 instead kf rhe corrent date 01 01 2012
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started