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
Create a base class named rectangle that contains lenght and width data members.
kumpel [21]

Answer:

class Rectangle:  

   

   def __init__(self, length, width):

       self.length = length

       self.width = width

       

   

   def area(self):

       area = self.length*self.width

       return area

   

   

class Box (Rectangle):

   

   def __init__(self, length, width, height):

       super().__init__(length, width)

       self.height = height

       

   def volume(self):

       volume = self.length * self.width * self.height

       return volume

   

   def area(self):

       area = 2*(self.length*self.width) + 2*(self.length*self.height) + 2*(self.width*self.height)

       return area

rec_1 = Rectangle(2,4)

box_1 = Box(2,2,6)

print(box_1.length)

print(box_1.area())

   

print(rec_1.length)

print(rec_1.area())

Explanation:

The programming language used is python.

class Rectangle

The class Rectangle is created with attributes length and width.

The class attributes are initialized using the __init__ constructor.

In the rectangle class, a method/function is declared to return the area of the rectangle.

class Box

This class is a child of rectangle and it inherits all its attributes and methods,

It has an additional attribute of depth and its constructor is used to initialize it.

The class contains a volume function, that returns the volume and an override function 'area()' that displaces the area from the parent class.

Finally, some instances of both classes are created.

4 0
3 years ago
In a spreadsheet, there are many features that help you edit quickly. True False
9966 [12]

Answer:

True

Explanation:

There are many form a quick editing

i hoped this helped

;)

7 0
3 years ago
Which windows system include new features and extends the functionality
Juli2301 [7.4K]

Critical update

Hope this helps!

3 0
3 years ago
Create and apply a CSS class named YellowBackground that selects a yellow background. Apply the class to your HTML file’s body t
masha68 [24]

Here is an HTML example with the CSS class defined inline:

<!doctype html>

<html>

 <head>

   <style>

  .YellowBackground {

 background-color : yellow;

  }

</style>

   

   </head>

 

   <body class="YellowBackground">

       <h1>A yellow background</h1>

   </body>

</html>

6 0
3 years ago
How do I cancel a friend request?
dusya [7]

Answer:

By pushing cancel

Explanation:

It's simple

3 0
3 years ago
Read 2 more answers
Other questions:
  • Jim, the IT director, is able to complete IT management task very well but is usually two weeks late in submitting results compa
    5·1 answer
  • I’m trying to get answers from Brainly and it’s not showing up. I’ve been refreshing the browser, but it’s the same. I’ve never
    10·2 answers
  • After a suspected identity fraud case has been resolved, you should:
    10·2 answers
  • Which operating system (OS) is used to run your laptop?
    15·2 answers
  • What is the major difference between the intranet and extranet?
    11·1 answer
  • Is an electronics standard that allows different kinds of electronic instruments to
    12·1 answer
  • What can i say back to my IT school lady?
    8·1 answer
  • What is the most common knowledge computer programmers need in order
    15·2 answers
  • Your friend decides to create a spreadsheet containing vocabulary terms and their definitions to help prepare for the unit test
    5·1 answer
  • you manage a network that has multiple internal subnets. you connect a workstation to the 192.168.1.0/24 subnet. this workstatio
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!