Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java, Convert a month name into a month name in title case and an ordinal number. Input: Read a month name. Process: Break the

in java, Convert a month name into a month name in title case and an ordinal number.
Input:
Read a month name.
Process:
Break the month name into two parts: first character and the remaining characters.
Convert the first part to uppercase.
Convert the second part to lowercase.
Combine the two converted parts into one and save it as the month name.
Assign a month number (1-12) or -1 to the month according to its name.
If the month name is January, save 1 as the month number.
else If the month name is February, save 2 as the month number.
else If the month name is March, save 3 as the month number.
else If the month name is April, save 4 as the month number.
else If the month name is May, save 5 as the month number.
else If the month name is June, save 6 as the month number.
else If the month name is July, save 7 as the month number.
else If the month name is August, save 8 as the month number.
else If the month name is September, save 9 as the month number.
else If the month name is October, save 10 as the month number.
else If the month name is November, save 11 as the month number.
else If the month name is December, save 12 as the month number.
else the month is invalid, save -1 as the month number.
Output:
Display the month name (January to December) or invalid and its ordinal number (1 st to 12 th)
or invalid according to its month number:
Case 1: The month is January, display January as the 1 st month.
Case 2: The month is February, display February as the 2 nd month.
Case 3: The month is March, display March as the 3 rd month.
Case 4: The month is April, display April as the 4 th month.
Case 5: The month is May, display May as the 5 th month.
Case 6: The month is June, display June as the 6 th month.
Case 7: The month is July, display July as the 7 th month.
Case 8: The month is August, display August as the 8 th month.
Case 9: The month is September, display September as the 9 th month.
Case 10: The month is October, display October as the 10 th month.
Case 11: The month is November, display November as the 11 th month.
Case 12: The month is December, display December as the 12 th month.
Case -1: The month is invalid, display invalid as an invalid month. Assign a month number:
o You must use if -else if- else statement for this part.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. Explain the 2nd world war. 2. Who is the father of history?

Answered: 1 week ago