Question: Oracle Academy - Java 3-2 Use Regular Expressions Lesson Powerpoint - https://drive.google.com/open?id=0B3GMuhuuq6eAcm9oVTBKUmJlTTA There is a student in your class that loves to bake cupcakes for

Oracle Academy - Java

3-2 Use Regular Expressions

Lesson Powerpoint - https://drive.google.com/open?id=0B3GMuhuuq6eAcm9oVTBKUmJlTTA

There is a student in your class that loves to bake cupcakes for peoples' birthdays, but since there are so many people in your class he cannot remember everyone's birthday! You decide to write a program that collects everyone's birthdays into an ArrayList of Dates called birthdays so that your classmate won't forget anymore.

The Date class is given below. Write a program that reads in a birthday from the user input, use Scanner and System.in to read the user input from the console as a string called bday. Each birthday will be entered in the format MM/DD/YYYY.

Create a Pattern for the date using groups. The first group will be the first two digits, store this group as String month. The second group will be the two digits for the day, do not include the slash (/) as part of any group and store the second group as String day. The third and final group will be the four digit year of the student's birth, store this as String year. Finally, create a new Date for each bday that you read in and add it to the ArrayList birthdays.

Hint: you will need to create a Matcher in order to store and access the groups of bday. If ever the string bday does not match the pattern, you have reached the end of the birthdays and therefore are done adding birthdays to the ArrayList.

public class Date{ public String month; 3

public String day; public String year;

public Date(String m, String d, String y){ month=m; day=d; year=y; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!