Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the United States, we commonly express dates by listing the month, then the day then the year, all separated by slash marks. In Europe,

In the United States, we commonly express dates by listing the month, then the day then the year, all separated by slash marks. In Europe, however, dates are commonly expressed by listing the day first, then the month, then the year, all separated by periods.

Write a JAVA application program that will get a line of text containing a date in US form from the user, and then change this date to European form.

Begin by asking the user to enter a date in the form of month/day/year. Store this date in a String variable.

Next, use the appropriate String methods to swap the month and day parts of the date, and replace the slash marks with periods. Print the revised String to the screen.

The following is an example of what you MIGHT see on the screen when your program runs. The exact output depends on what values that the user types in while the program runs. The user's values are shown below in italics:

Enter a date in the form mon/day/year: 06/17/2008 Your date in European form is: 17.06.2008

Here is another example run of the program:

Enter a date in the form mon/day/year: 5/3/09 Your date in European form is: 3.5.09

Technical Notes, Special Requirements and Hints:

You may assume that the user's inputted text will contain a correctly formatted US date. You don't have to worry about trying to do any error-checking in regards to this issue.

As you see from the examples above, however, the user may enter either 1 or 2 digits for the month and day and either 2 or 4 digits for the year. Your program should be able to handle all of these cases.

Hint: Use a String method to find where the slash marks are in the inputted String.

Hint: Once you know the locations of the slash marks, you will need to extract the portions of the String that appear before and after the slash marks and store them in separate String variables. Now you can form your new String by concatinating the pieces together in the proper order.

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Solve the following 1,4 3 2TT 5x- 1+ (15 x) dx 5X

Answered: 1 week ago