Question

In: Mechanical Engineering

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

In matlab.write a program that converts a numerical date given by the user into a month, day, and year. Specifically, the user should 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". Notice the "th" addition after the day. This changes depending on the number. Make sure this feature is included. MATLAB has built-in date conversion functions. You cannot use them in this exercise.

Solutions

Expert Solution

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)


Related Solutions

Write a c++ program that asks the user for a date (Month and Day only) and...
Write a c++ program that asks the user for a date (Month and Day only) and displays the season in this day.The program asks then the user if he needs to enter another date, if he answers with ’Y’ or ’y’, the programwill take another date from the user and displays the season in this day.The program will keep repeating this until the user enters a character different than ’Y’ and ’y’.•Fall starts in September 21st•Winter starts in December 21st•Spring...
Write Java program that asks a user to input a letter, converts the user input to...
Write Java program that asks a user to input a letter, converts the user input to uppercase if the user types the letter in lowercase, and based on the letter the user the user enters, display a message showing the number that matches the letter entered. For letters A or B or C display 2 For letter D or E or F display 3 For letter G or H or I display 4 For letter J or K or L...
Write a program that converts the user's number into the desired unit of measurement. The user...
Write a program that converts the user's number into the desired unit of measurement. The user will pick the desired unit from a menu shown below. Ask the follow-up question (the number to convert) and do the math ONLY if the user picks a valid choice from the menu. You can see the conversions / multipliers needed for this program in the output section below. Menu/Prompt: Enter the number that corresponds to your desired unit conversion from the choices below:...
Given the class Date that can prints the date in numerical form. Some applications might require...
Given the class Date that can prints the date in numerical form. Some applications might require the date to be printed in another form, such as October 1, 2020. Please do the following: Design the child class ExtDate based on the class Date (as a parent class) so that the date can be printed either form. Add a data member to the class ExtDate so that the month can also be stored in string form. Add a method to output...
2. Create a C++ program that converts the number of American dollars entered by the user...
2. Create a C++ program that converts the number of American dollars entered by the user into one of the following foreign currencies: Euro, British pound, German mark, or Swiss franc. Allow the user to select the foreign currency from a menu. Store the exchange rates in a four-element double array named rates. Notice that the menu choice is always one number more than the subscript of its corresponding rate. For example, menu choice 1's rate is stored in the...
Write a Java program that will ask the user for his/her salary (numerical integer salary) and...
Write a Java program that will ask the user for his/her salary (numerical integer salary) and then convert this numerical salary into income class. The following is a guideline to the income class used. The numeric range within parenthesis maps to the preceding class. If the user gave you a number greater than 700,000 or less than 10,000, you should print a message that the input is invalid. In this code, DO NOT USE && OPERATOR. You should use if-else....
Write a Java program that will ask the user for his/her mark (numerical integer mark) and...
Write a Java program that will ask the user for his/her mark (numerical integer mark) and then convert this numerical mark into letter grades. The following is a guideline to the grading scale used. The numeric range within parenthesis maps to the preceding letter grade. If the user gave you a number greater than 100 or less than 0, you should print a message that the input is invalid. In this code, DO NOT USE && OPERATOR. You should use...
Write a program that prompts the user to enter a person’s date of birth in numeric...
Write a program that prompts the user to enter a person’s date of birth in numeric form such as 8-27-1980. The program then outputs the date of birth in the form: August 27, 1980. Your program must contain at least two exception classes: invalidDay and invalidMonth. If the user enters an invalid value for day, then the program should throw and catch an invalidDay object. Follow similar conventions for the invalid values of month and year. (Note that your program...
Instructions Write a program in C# that converts a temperature given in Fahrenheit to Celsius. Allow...
Instructions Write a program in C# that converts a temperature given in Fahrenheit to Celsius. Allow the user to enter values for the original Fahrenheit value. Display the original temperature and the formatted converted value. Use appropriate value returning methods for entering (input), calculating, and outputting results.
Create a program that when run, prompts the user to enter a city name, a date,...
Create a program that when run, prompts the user to enter a city name, a date, the minimum temperature and the maximum temperature. Calculate the difference between the maximum temperature and the minimum temperature. Calculate the average temperature based on the minimum and maximum temperature. Print out the following: City name today's Date minimum temperature maximum temperature average temperature difference between minimum and maximum The following is a sample run, user input is shown in bold underline. Enter City Name:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT