/* * Intro to Programming CSE 1310 * University of Texas at Arlington */ package spr17mar23; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author jcmtiernan */ public class Spr17Mar23 { /** * @param args the command line arguments */ public static void main(String[] args) { Logger logger = Logger.getLogger(LoggingExamples.class.getName()); logger.setLevel(Level.OFF); //INFO is on; OFF is off PrintWriter outfile; try { outfile = new PrintWriter("timesOut.txt"); } catch (FileNotFoundException fnf) { outfile = new PrintWriter(System.out); } Scanner keybd = new Scanner(System.in); JCMTtimeMar21 myTime = new JCMTtimeMar21(); System.out.println("A default time value is "+myTime.toStringMDYHM()); JCMTtimeMar21 feb1Time = new JCMTtimeMar21(2017, 2, 28); System.out.println("A Feb 28 2017 value is "+feb1Time.toStringMDYHM()); outfile.println("A Feb 28 2017 value is "+feb1Time.toStringMDYHM()); JCMTtimeMar21 feb2Time = new JCMTtimeMar21(2017, 2, 29); System.out.println("A Feb 29 2017 value is "+feb2Time.toStringMDYHM()); outfile.println("A Feb 29 2017 value is "+feb2Time.toStringMDYHM()); JCMTtimeMar21 feb3Time = new JCMTtimeMar21(2016, 2, 29); System.out.println("A Feb 29 2016 value is "+feb3Time.toStringMDYHM()); outfile.println("A Feb 29 2016 value is "+feb3Time.toStringMDYHM()); JCMTtimeMar21 feb4Time = new JCMTtimeMar21(2016, 2, 30); System.out.println("A Feb 30 2016 value is "+feb4Time.toStringMDYHM()); outfile.println("A Feb 30 2016 value is "+feb4Time.toStringMDYHM()); JCMTtimeMar21 laterTime = new JCMTtimeMar21(); System.out.println("Original later time value is "+laterTime.toStringMDYHM()); laterTime.setHourInMil(22); System.out.println("laterTime value is "+laterTime.toStringMDYHM() +" hour = 22"); laterTime.setYear(1989); System.out.println("laterTime value is "+laterTime.toStringMDYHM() +" year = 1989"); laterTime.setMonth(2); System.out.println("laterTime value is "+laterTime.toStringMDYHM() +" month = 2"); System.out.println(""); int inMo = -1; int inDay = -1; int inYr = -1; int inHr = -1; int inMin = -1; System.out.println("Please enter the expiration date and time of your coupon.\n"); System.out.println("The format should be month (space) day (space) year (space) hour (space) min"); System.out.println("like MM dd yyyy HH mm. The coupon year must be between 1970 and 2020. "); System.out.println("The hour should be in military time from 0 to 23. Invalid values will be "); System.out.println("replaced with the current time values. Example: For a coupon that expires one"); System.out.println("minute before midnight on Halloween the input would be 10 31 2017 23 59. \n"); System.out.print("Enter your coupon expiration date and time here: "); inMo = keybd.nextInt(); inDay = keybd.nextInt(); inYr = keybd.nextInt(); inHr = keybd.nextInt(); inMin = keybd.nextInt(); //myTime.MONTH = 9; System.out.println("\nYour input was "+inMo +"/"+inDay+"/"+inYr+" at "+inHr+":"+inMin); JCMTtimeMar21 expDate = new JCMTtimeMar21(inYr, inMo, inDay, inHr, inMin); System.out.println("Your error-checked input is "+expDate.toStringMDYHM()); System.out.println("\nNow we will check if this coupon is still valid and how many\n" + "days longer it is valid or that it has been expired. "); outfile.close(); } }