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
The processing power of a computing device is measured by its _____.
Scilla [17]

Answer:

china

Explanation:

8 0
3 years ago
Which of the following best describes contextual design?
skelet666 [1.2K]

Answer:

B

Explanation:

3 0
3 years ago
If you want to place the insertion point in a cell to edit a specific part of its contents, you can
Vlad1618 [11]
Pretty sure,
A. Click The Cell
5 0
3 years ago
What does a for loop look for in the sequence of data? Check all that apply.
ValentinkaMS [17]

Answer:

All

Explanation:

Not sure on the context of this question, but a loop is generally used to iterate though every piece of data to perform some kind of operation, on everything in something like an array or string.

7 0
3 years ago
Read 2 more answers
Write code that prints: usernum ... 2 1 blastoff! your code should contain a for loop. print a newline after each number and aft
Svetradugi [14.3K]

You never said what language so I used C

#include <stdio.h>

<span>int main () { </span>

<span>  int a;  </span>

<span>  for( a = 3; a > 0; a-- ){ </span>

<span>      printf("%i \n", a); }</span>

<span>  printf(" Blast OFF !!!\n");   </span>

<span>return 0; </span>

<span>}</span>

4 0
3 years ago
Other questions:
  • WILL DO A BRAINLY! help pls.
    15·1 answer
  • Which of the following commands is more recommended while creating a bot?
    9·1 answer
  • The biggest factor in determining the price of a mortgage is:
    14·1 answer
  • Which of the following consists of electronic components that store instructions?
    10·1 answer
  • Anybody good with Microsoft excel? I need help with this class.
    9·2 answers
  • Place the steps in order to link and place text into the document outline, effectively creating a master document.
    8·1 answer
  • Which of the following JavaScript expressions is equivalent to the given HTML code? ​ a. Document.getelementbyId("menu1").menu=
    6·1 answer
  • The physical parts of the computer are known as?
    14·1 answer
  • Write if true or false
    11·1 answer
  • Please help me with coding!
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!