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 statement best describes an advantage of using the Subtotal dialog box?
SCORPION-xisa [38]
I think it's 2 i'm not sure
3 0
4 years ago
Read 2 more answers
try the following code to see a nullpointer error (if you don’t see the error because of the autograding, you can copy it into t
gavmur [86]

Using the knowledge of computational language in JAVA it is possible to describe  since s is null, indexof throws an nullpointer error for s. comment out the first if statement and run the program again. the second if statement avoids the error with shortcircuit evaluation.

<h3>Writting the code:</h3>

<em>public class Printer {</em>

<em>    private String name;</em>

<em>    public void print() {</em>

<em>        </em><em>printString</em><em>(name);</em>

<em>    }</em>

<em>public class Example {</em>

<em />

<em>    public static void </em><em>main</em><em>(String[] args) {</em>

<em>        Object obj = null;</em>

<em>        obj.hashCode();</em>

<em>    }</em>

<em />

<em>}</em>

<em>    public static void </em><em>main</em><em>(String[] args) {</em>

<em>        Printer printer = new Printer();</em>

<em>        printer.print();</em>

<em>    }</em>

<em>}</em>

<em>    }</em>

<em>public class Example {</em>

<em />

<em>    public static </em><em>void </em><em>main(String[] args) {</em>

<em>        Object obj = null;</em>

<em>        obj.hashCode();</em>

<em>    }</em>

<em />

<em>}</em>

<em>    public static void </em><em>main</em><em>(String[] args) {</em>

<em>        Printer printer = new Printer("123");</em>

<em>        printer.print();</em>

<em>    }</em>

<em>}</em>

See more about python at brainly.com/question/19705654

#SPJ1

4 0
1 year ago
over their whole lifetime about how much can someone with a professional degree expect to earn compared to someone with a highsc
Gemiola [76]

Really depends on the job most college based technology jobs pay about 100k 76k after taxes. Mechanics could range above that. Without a college degree most people don't make it above 30k. Thats not what i know for sure just of what i've seen.

4 0
4 years ago
You are creating a game in which an enemy sprite performs a certain action
cluponka [151]

The repeat loop is the best type of loop to be used in a game where the enemy sprite performs a certain action five times and then stops.

<h3>What is repeat loop?</h3>

In programming, the repeat loop is used when the programmer want to execute one or more statements repeatedly some number of times.

Hence, the repeat loop is the best type of loop to be used in a game where the enemy sprite performs a certain action five times and then stops.

Therefore, the Option C is correct.

Read more about repeat loop

<em>brainly.com/question/7145214</em>

5 0
3 years ago
Create a story that depicts the events leading up to a vehicle crash fatality, the crash itself, and the emotional aftermath on
Brilliant_brown [7]

Answer:

About 5 years ago my girlfriend and I were taking a summer camping trip in southern Alberta. I was in the passenger seat trying to find the campground on a map when she drove over the crest of a hill, was blinded by the sun drove into the ditch. It was a seriously steep ditch but we weren't going very fast so all was fine. I looked over at her and laughed before returning my attention to the map, assuming she could safely bring the vehicle back onto the road.

The next thing I knew, the SUV launched onto the pavement and she lost control and we began swerving. I remember feeling the wheels on the driver's side lift off the ground, then the impact as I was slammed into the door and glass exploded into my face. We barrel rolled and we rolled over-front for a seriously long way.

At some point during the chaos I looked over at her to make sure she was "ok", and just as I did so I watched as she was thrown into the ground through her door window and the corner of the roof just above her seat was crushed inward. The way it looked to me was that she had just been crushed between the ground and the roof of the vehicle. I passed out at that point.

When I came to I had somehow already unbuckled myself from my seat and the vehicle was on its roof. I crawled over to her seat and was in absolute shock to see that she was still in one piece. I removed her from her seat and got us out through the windshield before carrying her for about a half a kilometer down the road, still in shock and fueled entirely by adrenaline.

We were found by a driver who had gone past the wreckage and we were eventually taken to a hospital. I broke 3 ribs on my right side and dislocated my right shoulder, she was severely concussed and scraped up but otherwise mostly okay. However she was 7 weeks pregnant at the time and we found out while in hospital that her body had rejected it under the immense and sudden stress.

We are still together and have 3 amazing and beautiful children, but she still holds onto a lot of guilt surrounding the accident and the loss.

Explanation:

4 0
3 years ago
Other questions:
  • Why don't we get together to watch the Academy Awards?
    15·2 answers
  • What is computer engineering?
    11·1 answer
  • Does a soda vending machine Give reciepts?<br><br>need for computer science hw
    7·2 answers
  • How to be professional in graphic design without CAD?
    5·1 answer
  • When you tap or click the ____ button for a selected graphic, Word provides options for changing how a graphic is positioned wit
    5·1 answer
  • Why is Linux widespread in academic environments?
    7·1 answer
  • Along a road lies a odd number of stones placed at intervals of 10 metres. These stones have to be assembled around the middle s
    12·1 answer
  • In python:
    8·1 answer
  • What is one disadvantage of transmitting personal data using digital signals?
    15·2 answers
  • What are the data type(s) will be used to declare the variable(s) needed to
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!