Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Event Schedule Table | Parsing Dates and Formatting Tables
Quizzes & Challenges
Quizzes
Challenges
/
Formatting & Parsing in Java

bookChallenge: Event Schedule Table

In this challenge, you are asked to bring together your knowledge of date parsing and string formatting to present a schedule of events in a clear, readable table printed to the console. You will implement a method called formatEventTable that takes three lists: event names, event dates, and attendee counts. The method will return a string representing a table with three columns: the event name, the date (formatted as "MMM dd, yyyy"), and the number of attendees. Each column should be properly aligned so the table is easy to read, regardless of the length of the event names or numbers. This exercise will help you practice combining date formatting with aligned table output using String.format and related techniques.

Tâche

Swipe to start coding

Implement the formatEventTable method so that it returns a string representing a formatted table of events. Each row should show the event name, the date formatted as "MMM dd, yyyy", and the attendee count. The columns must be aligned and wide enough to fit the longest value in each column, including the headers.

  • Format each date in the "MMM dd, yyyy" pattern.
  • Set each column's width to fit the longest value in that column.
  • Align event names and dates to the left, and attendee counts to the right.
  • Include a header row and a separator row.
  • Return the complete table as a single string.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 6
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Suggested prompts:

Can you provide an example input and the expected output for the table?

What date formats should the input dates be in?

Are there any specific alignment or width requirements for the table columns?

close

bookChallenge: Event Schedule Table

Glissez pour afficher le menu

In this challenge, you are asked to bring together your knowledge of date parsing and string formatting to present a schedule of events in a clear, readable table printed to the console. You will implement a method called formatEventTable that takes three lists: event names, event dates, and attendee counts. The method will return a string representing a table with three columns: the event name, the date (formatted as "MMM dd, yyyy"), and the number of attendees. Each column should be properly aligned so the table is easy to read, regardless of the length of the event names or numbers. This exercise will help you practice combining date formatting with aligned table output using String.format and related techniques.

Tâche

Swipe to start coding

Implement the formatEventTable method so that it returns a string representing a formatted table of events. Each row should show the event name, the date formatted as "MMM dd, yyyy", and the attendee count. The columns must be aligned and wide enough to fit the longest value in each column, including the headers.

  • Format each date in the "MMM dd, yyyy" pattern.
  • Set each column's width to fit the longest value in that column.
  • Align event names and dates to the left, and attendee counts to the right.
  • Include a header row and a separator row.
  • Return the complete table as a single string.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 6
single

single

some-alt