23.8k views
5 votes
Write a date transformer program using an if/elif/else statement to transform a numeric date in month/day format to an expanded US English form and an international Spanish form; for example, 2/14 would be converted to February 14 and 14 febrero

User Supraj V
by
5.3k points

1 Answer

2 votes

I wrote it in Python because it was quick so i hope this is helpful

Answer:

date = input('Enter Date: ')

split_date = date.split('/')

month = split_date[0]

day = split_date[1]

if month == '1':

english_month = 'January'

spanish_month = 'Enero'

elif month == '2':

english_month = 'February'

spanish_month = 'Febrero'

elif month == '3':

english_month = 'March'

spanish_month = 'Marzo'

elif month == '4':

english_month = 'April'

spanish_month = 'Abril'

elif month == '5':

english_month = 'May'

spanish_month = 'Mayo'

elif month == '6':

english_month = 'June'

spanish_month = 'Junio'

elif month == '7':

english_month = 'July'

spanish_month = 'Julio'

elif month == '8':

english_month = 'August'

spanish_month = 'Agosto'

elif month == '9':

english_month = 'September'

spanish_month = 'Septiembre'

elif month == '10':

english_month = 'October'

spanish_month = 'Octubre'

elif month == '11':

english_month = 'November'

spanish_month = 'Noviembre'

elif month == '12':

english_month = 'December'

spanish_month = 'Diciembre'

US_English = f'{english_month} {day}'

International_Spanish = f'{day} {spanish_month}'

print(f'US English Form: {US_English}')

print(f'International Spanish Form: {International_Spanish}')

Input:

3/5

Output:

US English Form: March 5

International Spanish Form: 5 Marzo

Step-by-step explanation:

You start by taking input from the user then splitting that at the '/' so that we have the date and the month in separate variables. Then we have an if statement checking to see what month is given and when the month is detected it sets a Spanish variable and an English variable then prints it to the screen.

Hope this helps.

User Pradatta
by
5.5k points