Skip to main content

Assignment #4

 

Text-based Trivia Application

Filenames: TextTrivia.java

Write a text-based application which will list today's trivia events to the console. Ask the user for today's month and day (from the keyboard), then read the class's trivia file (two versions available from our course web site). Read the records, and if the month and day from the trivia event match the user's input, display the year and event to the console.

Check for the following data entry errors:

1. invalid month number (should be 1-12)

2. invalid day number (minimum day number is 1; if month==1, 3, 5, 7, 8, 10, or 12,
     maximum day number is 31; if month==4, 6, 9, or 11,
     maximum day number is 30; if month==2, maximum day number is 29)

Display the appropriate trivia events, plus a count of the number of events listed.

The trivia file:

Two versions of the trivia file are available on our private course web site:

1. Trivia.dat contains variable-length, delimited fields (using a tab as the delimiter character). When you read a record from this file, you can break it apart using the String class's split() method.

2. Trivia.fil contains fixed-length fields. You can extract individual fields from this record by using the String class's substring() method.