In matlab.write a program that converts a numerical date given by the user into a month,...

Free

60.1K

Verified Solution

Question

Mechanical Engineering

In matlab.write a program that converts a numerical date givenby the user into a month, day, and year. Specifically, the usershould input a sequence of eight numbers 05141956.

the program should print out the same date in complete format.In this example it would print \"The date is May 14th, 1956\". Noticethe \"th\" addition after the day. This changes depending on thenumber. Make sure this feature is included. MATLAB has built-indate conversion functions. You cannot use them in thisexercise.

Answer & Explanation Solved by verified expert
4.4 Ratings (943 Votes)

NumericDate = input('Enter 8 digit Numeric Date: ','s')
monthNumber= substr(NumericDate,1,2)
if (monthNumber=='01')
MonthName='January'
elseif (monthNumber=='02')
MonthName='February'
elseif (monthNumber=='03')
MonthName='March'
elseif (monthNumber=='04')
MonthName='April'
elseif (monthNumber=='05')
MonthName='May'
elseif (monthNumber=='06')
MonthName='June'
elseif (monthNumber=='07')
MonthName='July'
elseif (monthNumber=='08')
MonthName='August'
elseif (monthNumber=='09')
MonthName='September'
elseif (monthNumber=='10')
MonthName='October'
elseif (monthNumber=='11')
MonthName='November'
else
MonthName='December'
end
Year = substr(NumericDate,5,4)
Day = substr(NumericDate,3,2)
Date = strcat(MonthName,' ',Day,'th, ',Year)


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students