1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sever21 [200]
3 years ago
13

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 d

ate 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. Please note that users are allowed to input the year in two digits or four digits, and input the month and day in one digit or two digits. Your program should be able to handle all possible cases.
Computers and Technology
1 answer:
rosijanka [135]3 years ago
6 0

Answer:

The Java code is given below with appropriate comments as well as the sample output

Explanation:

import java.util.Scanner;

public class Main

{

  public static void main(String[] args) {

System.out.println("Enter a date in the form mon/day/year:");

Scanner scanner = new Scanner(System.in);

String inputDate = scanner. nextLine();

 

//Split the string string with / as the delimiter

String[] dateComponents = inputDate.split("/");

 

//Rearrange the date and month part and join with '.' as sepertor

String outputDate = String.join(".", dateComponents[1], dateComponents[0], dateComponents[2]);

 

System.out.println("Your date in European form is:\n" + outputDate);

  }

}

<u>Sample Output </u>

Output 1:

Enter a date in the form mon/day/year:

01/22/2020

Your date in European form is:

22.01.2020

Output 2:

Enter a date in the form mon/day/year:

1/22/20

Your date in European form is:

22.1.20

You might be interested in
What is the difference between the Paste Special and Paste Link options?
kotegsom [21]
Paste Link lets you automatically update the referenced document.
8 0
4 years ago
Read 2 more answers
How can social media give you knowledge
cupoosta [38]
Social Media can you knowledge by most users on Social Media spreading their own knowledge.
5 0
3 years ago
Frrrrrrrrrrreeeeeeeeee brainliest for u
sukhopar [10]

Answer:

Yay I want brainliest

Explanation:

5 0
3 years ago
Read 2 more answers
Suppose you are implementing the address book feature for a cellphone. The address book needs to be kept sorted by person’s last
NemiM [27]

Answer:

Sorted linked list

Explanation:

  • A sorted linked list can be used for sorting the last name and support fast access while queried by the last name.
  • The hash table cannot be used because it could have a problem if there would be more buckets to handle than the expected.
  • The binary search table is implemented as the hash table hence both will give the same results.
8 0
3 years ago
When you open a new presentation, a slide with the default ____ layout appears.
arsen [322]
When you open a new presentation, a slide with the default title slide layout appears.
4 0
3 years ago
Other questions:
  • What is a Software Quality Assurance Audit?
    12·1 answer
  • Which topology connects all the computers in a circular pattern
    13·2 answers
  • Describe two ways the ARPANET is different from the internet
    12·1 answer
  • Create a program asks a user for an odd positive integer. If the user gives and even number or a number that is negative it prom
    7·1 answer
  • Most editing commands in Word, such as cut, copy, and paste, can be found on which tab?
    9·2 answers
  • Plz help me of this answer<br><br><br>language:python​
    7·2 answers
  • The process of using or controlling two or more windows at a time is known as. a threading .b multitasking. c hyperthreading.d s
    13·1 answer
  • USB flash drives are small portable units that are used to ____________files.
    5·2 answers
  • What type of light comes from reflections off other objects?
    5·1 answer
  • Which statement best describes the logic in a while loop?bringing an umbrella to determine if it is rainingbringing an umbrella
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!