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
Which of the following is an example of an output device on a smartphone?
Andru [333]

Answer:

The speaker

Explanation:

Speakers are output devices because the audio is taken from the app or website and playing it towards the speakers.

7 0
3 years ago
Why are peripherals added to computers?
Novay_Z [31]

Answer:

To expand their capabilities

Explanation:

They allow users to do more with computers

7 0
3 years ago
He ____ content of a web page contains information used by search engines to help users find your website.
luda_lava [24]
The header content of a web-page can contain meta tags that classify the page. Search engines use this information.
6 0
4 years ago
write a function that returns a list, where each member of list contains previous day’s value multiplied by 2.​
sergeinik [125]

Answer:

Explanation:

The following code is written in Java, the function takes in a list with the previous day's values. The function then uses that list, loops through it and multiplies each individual value by 2 and returns the modified list. The first red  square represents the test case for the function, while the second red square in the image represents the output.

 public static ArrayList<Integer> doubleIt(ArrayList<Integer> mylist) {

       for (int x = 0; x<mylist.size(); x++) {

           mylist.set(x, mylist.get(x)*2);

       }

       return mylist;

   }

5 0
3 years ago
Which of these apps could be a Trojan Horse designed to install malware on your system? Select all that apply. *
____ [38]

Answer:

Probably the third one

Explanation:

The ring tone apps are most likely designed to do that kind of stuff

7 0
3 years ago
Other questions:
  • When using NAND gate instead of NOR gate in SR flip-flop, Q and Q’ both become one when?
    12·1 answer
  • You can initialize more than one variable in a for loop by placing a(n) ____ between the separate statements.
    10·2 answers
  • An example of hardware is a _____. a)word processor b)database c)motherboard d)internet
    15·2 answers
  • When records are in ____ order, they are arranged one after another on the basis of the value in a particular field.?
    9·1 answer
  • Which term is used to describe individuals who want to attack computers yet lack the knowledge of computers and networks needed
    12·1 answer
  • TRUE OR FALSE !!!!
    7·2 answers
  • Henry is having a problem with the electrical system on his current laptop. The battery for the laptop will not charge. Henry to
    13·1 answer
  • In your own words, describe invention.
    8·2 answers
  • Match the feature to its function.
    7·1 answer
  • 1. A _______ causes the computer program to behave in an incorrect or unexpected way.
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!