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
stira [4]
3 years ago
5

LAB: Parsing dates in M/D/Y format

Computers and Technology
1 answer:
stira [4]3 years ago
8 0

Answer:

Explanation:

The following is written in Java and takes in a single input, tests if it is in the correct format and then outputs the new desired format.

import java.util.*;

import java.util.regex.Pattern;

class ChangeDate

{

   public static void main(String args[])

   {

       String mo,da,yr;

       Scanner input=new Scanner(System.in);

       boolean next = true;

       while (next == true) {

           System.out.print("Enter month::");

           String userDate = input.nextLine();

           if (userDate.equals("-1")) {

               next = false;

           }

           if (Pattern.matches("\\d\\d\\S\\d\\d\\S\\d\\d\\d\\d", userDate)) {

               mo = userDate.substring(0, 2);

               da = userDate.substring(3, 5);

               yr = userDate.substring(6, 10);

               System.out.println(getMonth(mo) + " " + da + ", " + yr);

           }

       }

 

   }

   public static String getMonth(String month) {

       switch (month) {

           case "01":

               return "January";

           case "02":

               return "February";

           case "03":

               return  "March";

           case "04":

               return  "April";

           case "05":

               return "May";

           case "06":

               return "June";

           case "07":

               return "July";

           case "08":

               return "August";

           case "09":

               return "September";

           case "10":

               return"October";

           case "11":

               return"November";

           case "12":

               return "December";

           default:

              return "Wrong Month Date";

   }

}}

You might be interested in
What type of software is needed access the internet
VLD [36.1K]

Google Chrome, Firefox, Internet explorer, etc....

4 0
3 years ago
Read 2 more answers
What is the radix transformation method?
alex41 [277]
A method of transformation that involves changing the radix or base of the original key and either discarding excess high-order digits (that is, digits in excess of the number desired in the key) or extracting some part of the transformed number.
4 0
3 years ago
Crashing almost always accelerates the schedule while increasing project risk, whereas fast tracking almost always accelerates t
Ivahew [28]

Answer: False

Explanation: Because fast-tracking doesn’t involve additional resources, it’s usually best to start with this technique while Crashing requires careful planning to prevent “panic mode” among the project crews and to avoid acceleration claims.

4 0
3 years ago
In which type of market do farmers sell their produce directly to village traders in rural areas?
Anna007 [38]

Answer:

Local Market or Primary Market.

Explanation:

The farmers sell their products to big traders in the bigger market in the urban areas. However, they also sell a part of their products to various village traders, who are located in the rural areas and can be found in local or primary markets. It's not so that they are not useful as well, as small farmers, in fact, sell the whole of their produce in the local or primary market as we know them by name. And the farmer gets a reasonable return there as well.

8 0
4 years ago
. In the BorderLayout class, what are NORTH, SOUTH, EAST, WEST, and CENTER?
ycow [4]

Answer:

A BorderLayout corresponds to a layout type where the components are organized along geographical directions represented by NORTH, SOUTH, EAST, WEST, and CENTER.

Explanation:

The layout class is awt determines the actual placement of components in the user interface. BorderLayout is a layout where the components are organized along geographical directions represented by NORTH, SOUTH, EAST, WEST, and CENTER. For example:

Panel p = new Panel();

p.setLayout(new BorderLayout());

p.add(new TextArea(), BorderLayout.CENTER);

p.add(new Button("Close"), BorderLayout.SOUTH);

This code segment will add a textarea at the CENTER of the interface and a button 'Close' towards the SOUTH.

8 0
3 years ago
Other questions:
  • How do the search methods differ for primary and secondary data?
    10·2 answers
  • A(n) _____ can be used to convert digitized documents into ascii (american standard code for information interchange) text that
    6·1 answer
  • Data ____ travel over the Internet from router to router until reaching their destinations.
    7·1 answer
  • What tasks do most operating systems perform?
    15·1 answer
  • __________ can be used to replace internal network addresses with one or more different addresses so the traffic that actually t
    9·1 answer
  • Does clicking ads and pop ups like the one shown in this image could expose your computer to malware?
    15·1 answer
  • Create a class named Lease with fields that hold an apartment tenant’s name, apartment number, monthly rent amount, and term of
    13·1 answer
  • You're working in a table that has three columns and five rows. Since the first row will be a header row, you want it to span al
    6·1 answer
  • You were recently hired by a small start-up company. The company is in a small office and has several remote employees. You have
    15·1 answer
  • you are investigating the use of website and url content filtering to prevent users from visiting certain websites. which benefi
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!