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 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:...
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:...
I need to make this program which supposed to accept the date form the user in...
I need to make this program which supposed to accept the date form the user in format of YYYY-MM-DD and output the corresponding date in its expanded format. output should be something like: Enter the date in YYYY-MM-DD: 2020-10-03 October o3, 2020 (in C++) I have this program but there are some errors that I couldn't find. // Lab3_Project_jk.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include<iostream> #include<string> using namespace std; int main()...
C++ The program implements the Number Guessing Game. However, in that program, the user is given...
C++ The program implements the Number Guessing Game. However, in that program, the user is given as many tries as needed to guess the correct number. Rewrite the program so that the user has no more than five tries to guess the correct number. Your program should print an appropriate message, such as “You win!” or “You lose!”.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT