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
It is easy to create good photographs of mountains because you can always tell how big they are. True False
Tanya [424]

False

From afar it may be difficult to be sure how big the mountains actually are

5 0
3 years ago
Read 2 more answers
What aviation first is janice brown credited with
Alla [95]

Janice Brown is a former teacher who flew the first long-distance solar-powered flight. She flew a small experimental solar-powered aircraft six miles.

Let me know if you have any questions.

7 0
2 years ago
What can you search on Microsoft Word or Powerpoint Clipart or Google (Clip art) to find more pictures like the ones below but w
elena-14-01-66 [18.8K]
Well if you put sad/mad/scared/tired/ect it should pop up with the same person.
3 0
3 years ago
What is the easiest computer programming language​
RideAnS [48]

Answer:

Ther are 8 easiest computer programming language :

• HTML

• CSS

• Javascript

• Python

• Ruby

• Java

• PHP

• C/C++

5 0
3 years ago
Uter 110 Marks )
Alexxandr [17]

Answer:

Sent me a message that I was paying R319 for the

4 0
2 years ago
Other questions:
  • Unix has experimented with several security programs. a user can attach a watchdog program to a file that grants or denies acces
    13·1 answer
  • Which of the following is a typical concern for developers while using prototypes?
    6·2 answers
  • _____ separation strategies (e.g., attacking and sabotaging others) are used by those for whom co-cultural segregation is an imp
    5·1 answer
  • What does the following loop do?
    5·1 answer
  • How do I insert a row above the selected row in between row and row 2 revenue xls
    5·1 answer
  • How many of you got the right answer from this app​
    8·1 answer
  • What is the code for this please?​
    13·1 answer
  • Arrange the steps involved in natural language generation.
    9·1 answer
  • Explain the term creating in word processing​
    12·1 answer
  • unlike the barcode-based tracking system, a radio frequency identification system offers a .
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!