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
mr Goodwill [35]
2 years ago
10

LAB: Parsing dates Complete main() to read dates from input, one date per line. Each date's format must be as follows: March 1,

1990. Any date not following that format is incorrect and should be ignored. Use the substr() function to parse the string and extract the date. The input ends with -1 on a line alone. Output each correct date as: 3/1/1990 Ex: If the input is March 1, 1990 April 2 1995 7/15/20 December 13, 2003 -1 then the output is: 3/1/1990 12/13/2003 LAB ACTIVITY 9.10.1: LAB: Parsing dates 0/10 main.cpp Load default template - COLE > 5 6 int DateParser(string month) 7 int monthInt = 0; if (month January) 10 monthint - 11 11 else if (month -- "February") 12 monthint - 21 13 else if (month - "March) montrent - 3; 15 else if (month -- "April") 16 monthInt - 4 else if (month "ay") monthint - 5 19 else if (month June") antin 6 21 else if (monthuly) 22 monthint - 7 else if (monthst") monthiet 8 LAB ACTIVITY 9.10.1: LAB: Parsing dates main.cpp 22 monthint - 1 23 else if (month == "August") 24 monthInt = 8; 25 else if (month - "September") 26 monthInt = 9; 27 else if (month -- "October") 28 monthInt - 10; 29 else if (month - "November") 30 monthInt - 11; 31 else if (month - "December") 32 monthInt = 12; 33 return monthint; 34 ) I 35 36 int main() { 37 38 // TODO: Read dates from input, parse the dates to find the one 39 1 in the correct format, and output in m/d/yyyy format 40 41) 42
Computers and Technology
1 answer:
Vladimir [108]2 years ago
6 0

The python code which can be used to read dates from input, one date per line and each date's format must be as follows: March 1, 1990, is:

<h3>Python code</h3>

import datetime

inputs = []

result = []

#read the inputs

date = input()

inputs.append(date)

while not date == "-1":

 date = input()

 inputs.append(date)

#check if the input is in the correct format and convert it.

for date_text in inputs:

 try:

   date_text = datetime.datetime.strptime(date_text,"%d %B, %Y")

   result.append(date_text.strftime("%d/%m/%Y"))

 except ValueError:

   pass

   

print(*result, sep = "\n")

The above code would parse the string and extract the date. The split() method was used to break the input into tokens.

Read more about python programming here:

brainly.com/question/27666303

#SPJ1

You might be interested in
When is it appropriate to delete an entire row or column as opposed to deleting the data in the row or column
borishaifa [10]

Answer:

huh wdym

Explanation:

7 0
3 years ago
Dharma opens one window, does a little work, closes the window and then opens a new one. Instead of opening windows, what can Dh
seraphim [82]

Answer:

Make a goal

Explanation:

She could make a goal achieve it and reward herself. Do this multiple times and she will be done

5 0
3 years ago
Write a loop that fills a list values with ten random numbers between 1 and 100. Write code for two nested loops that fill value
Alex787 [66]

Answer:

Please look for your answer on Stack Overflow, it's way better.

Explanation:

4 0
3 years ago
Using reliable internet sources, identify three ways we use analog and digital signals in our everyday lives.
Montano1993 [528]
Clocks maybe is the answer. I really don’t know
7 0
3 years ago
Explain three of the the features of the word processing to document. ​
boyakko [2]

Word processing software may be used to create, edit, save, and print documents, among other things. Text within a document may be copied, pasted, moved, and deleted. Text formatting includes font selection, bolding, underlining, and italicizing.

4 0
2 years ago
Read 2 more answers
Other questions:
  • Which of the following is not an assessment of your fitness to drive
    14·1 answer
  • What is the simplest unit of a compound that maintains all the characteristics of the compound<br> ?
    9·1 answer
  • 1. Create an interface called Runner. The interface has an abstract method called run() that display a message describing the me
    8·1 answer
  • What is the term used for describing the judgement or common sense part of problem solving​
    11·1 answer
  • _____ are independent and not associated with the marketing efforts of any particular company or brand.​
    9·1 answer
  • In Microsoft Word you can access the _______ command from the "Mini toolbar." 
    9·1 answer
  • What is network topology? PLZZZ HURRY
    9·1 answer
  • True or false :User intent refers to what the user was trying to accomplish by issuing the query
    13·1 answer
  • WHAT DOES INFORMATION TECHNOLOGY DO??<br> Do they offer services or products
    15·1 answer
  • 17. What is something an employer might look for in person when hiring? (3
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!