import java.util.Scanner; /* * Lab 6 Tutorial 2 * * Description: Takes a date in dd/MM/yyyy format and prints in format Month Day, Year * INPUT: Date in dd/MM/yyyy format. * OUTPUT: Date in Month Day, Year format. */ public class Tutorial2 { public static void main(String[] args) { for (int i=0; i < 3; i++) { Scanner sc = new Scanner(System.in); System.out.print("Enter input date in dd/MM/yyyy format: "); String orgDate = sc.next(); String convertedDate = Tutorial2.convertDate(orgDate); System.out.println("The date "+orgDate+" entered is: "+convertedDate); } } public static String convertDate(String inputString) { int month, day, year; boolean invalidInput = false; String dateString=""; day = Integer.parseInt(inputString.substring(0,2)); month = Integer.parseInt(inputString.substring(3,5)); year = Integer.parseInt(inputString.substring(6,inputString.length())); switch (month) { case 1: dateString = "January"; break; case 2: dateString = "February"; break; // TODO: Fill in the rest of the cases default: invalidInput = true; break; } // TODO: Check to see if the day is in between 1 and 31 // If it is not, set invalidInput, otherwise build up day part of dateString // TODO: Check to see if the year is in between 1000 and 3000 // If it is not, set invalidInput, otherwise build up year part of dateString // TODO: Return INVALID if input is invalid, otherwise return the dateString } // end of convertDate() } // end of Tutorial2