Starting from:

$24.99

Assignment 2_Translate the Date

Assignment 2
1. Translate the Date (35 marks)
An important part of software systems is to ensure that they can function equally well in any of the world’s many languages. One method to allow this is to read “localization” data from files, rather than hard-coding directly into source code. We can define a localization file format needed for translating dates as a 2-line text files that contains the names of all 7 days of the week on one line (space separated) and the 12 months of the year on a second line.
Now we can sort of change languages (we must ignore forming proper sentences for now) just by pointing our program to a different file. 3 samples are provided as: english_labels.txt, french_labels.txt, and spanish_labels.txt.
Write a program that translates dates by:
● Accepting a date on standard input (can be typed on the terminal, but more to the point, will be piped to you from “date”). ● Accepts one and only command-line argument: the path to a language file with the format described above ● Outputs a date with the same format as the input, but with both the day name and the month name translated as requested (output the full day and month names, not date’s typical 3 letter version).
(Note the --date=... option of the date command lets you easily test different months and days quickly without having to wait overnight)
2. Multi-Language Calendar (65 marks)
Write a program that prints one year’s full calendar to standard output following a precise output format. The language of the calendar will be configurable based on the same input text format as Question 1. Your program will accept exactly 3 command-line arguments: ● Language file as the path to a text file as was described above ● Maximum number of characters DAYSIZE to print for the day-of-week labels, which must be 2 or greater ● The day-of-week that starts the year as an integer from 1 to 7 (1 is Sunday in English) Your output must precisely follow these examples (text specification to follow):
(Note that the image just shows the first 3 months of the calendar to fit on the page, but your output must continue for the full year)
12 months are printed. Each month is composed of: ● A line of star characters that span the calendar’s full width (max of any other line specified) ● A line composed on a single star, a single space and the month’s name in the requested language ● A line of star characters that span the calendar’s full width ● A line with 7 columns worth of day labels, where each day label contains, in order: ○ A single star ○ A single space ○ A day-of-week label cut down to DAYSIZE characters if the label is too long ○ Additional spaces to pad up to DAYSIZE if the label was too short ○ A single space ● A line of star characters that span the calendar’s full width ● 5 or 6 lines that contain the days of that month: ○ Print exactly 30 days always (avoids leap-years etc). ○ Lay out the date numbers with the usual logic: ■ The first day of one month is on the day following the last day of the previous month ■ When a week is not “full” with dates, blank days are printed to maintain spacing, both at the start and end of the month ● Each day section must contain, in order: ○ A single * ○ A single space ○ The date as a one or two digit integer, following correct ordering ○ Additional spaces to pad up to DAYSIZE if the number was too short ○ A single space

Submitting your solutions:
You will submit a single zip file that contains the 2 C files holding your solutions. Create the zip file with the command: $ zip A2_solutions.zip q1.c q2.c

More products