Question

can you please help with this problem? [L8-2] (date_parse.java) Complete the provided code, finishing the function...

can you please help with this problem?

[L8-2] (date_parse.java) Complete the provided code, finishing the function parse_date(dstring). When called, pass dstring as mm/dd/yyyy, where mm, dd, and yyyy are integers. The function should split dstring into individual strings, convert each to integer month, day, and year, then return the tuple (month,day,year). The provided main() reads date as a str value from the user, calls parse_date(date), then prints out the returned result.

Note: the starting code is here:

def parse_date(dstring):
    ''' parse dstring as mm/dd/yyyy and return in tuple (mm,dd,yyyy)'''
    pass

def main():

    date = input ("Enter date in form mm/dd/yyyy: ")

    result = parse_date(date)

    print (result)

main()
0 0
Add a comment Improve this question Transcribed image text
Answer #1

def parse_date(dstring):

    string = dstring.split("/")

    return (string[0],string[1],string[2])

def main():

    date = input ("Enter date in form mm/dd/yyyy: ")

    result = parse_date(date)

    print (result)

main()

================================
SEE OUTPUT


Thanks, PLEASE COMMENT if there is any concern

Add a comment
Know the answer?
Add Answer to:
can you please help with this problem? [L8-2] (date_parse.java) Complete the provided code, finishing the function...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need help writing beginner C# program, I will make sure to provide feedback to whoever can...

    Need help writing beginner C# program, I will make sure to provide feedback to whoever can help me figure it out! No public or global variables should be used. You need to consider passing arguments between the methods according to the ways described in the lecture. i.e. all variables should be declared inside the methods and passed to other methods by value/ref/out as needed Description: We want to design a Date class to represent a date using three integer numbers...

  • Finish the program. Follow the program logic and then complete the algorithm in the function. Use...

    Finish the program. Follow the program logic and then complete the algorithm in the function. Use the programs given constructs and variables only. #include <iostream> #include <string> using namespace std; // Prototype string format(string); int main() { // The following string will hold the user's input. string userDate; // The following string will hold the formatted date. string formattedDate; // Get a date from the user. cout << "Enter a date in the form mm/dd/yyyy: "; cin >> userDate; //...

  • Create a Java application named Problem14 using the two files Dr. Hanna provided to you—Date.java andProblem14.java—then change his code to add two non-trivial public, non-static methods to the Date class.

    Create a Java application named Problem14 using the two files Dr. Hanna provided to you—Date.java andProblem14.java—then change his code to add two non-trivial public, non-static methods to the Date class.1. Increment a Date to the next day (for example, 1-31-2011 increments to 2-1-2011; 12-31-2010 increments to 1-1-2011).2. Decrement a Date to the previous day (for example, 2-1-1953 decrements to 1-31-1953; 1-1-1954 decrements to 12-31-1953).. Extra Credit (up to 5 points) Re-write the Date member functions Input() and Output() to usedialog boxes to...

  • Please read the problem carefully and answer the 2 questions below code: /***************************************************************** * Program: palindrome.c...

    Please read the problem carefully and answer the 2 questions below code: /***************************************************************** * Program: palindrome.c * * Purpose: implements a recursive function for determining *   if a string is a palindrome * * Authors: Steven R. Vegdahl, Tammy VanDeGrift, Martin Cenek * *****************************************************************/ #include #include #include /***************************************************************** * is_palindrome - determines whether a string of characters is a palindrome * * calling sequence: *    result = is_palindrome(str, first_index, last_index) * * parameters - *    str - the string to test *    first_index -...

  • Help please: A Modular Function: You must rewrite the code to use a modular function that...

    Help please: A Modular Function: You must rewrite the code to use a modular function that can be used again by other modules. Your main program will call the function and pass the variables by value. Your function will take the appropriate action and return the required value . (Hint you will use additional variables in your revised code). The called function must be able to accept the data passed to it by the function doing the calling. Only after...

  • Please write a code in python! Define and test a function named posterize. This function expects...

    Please write a code in python! Define and test a function named posterize. This function expects an image and a tuple of RGB values as arguments. The function modifies the image like the blackAndWhite function, but it uses the given RGB values instead of black. images.py import tkinter import os, os.path tk = tkinter _root = None class ImageView(tk.Canvas): def __init__(self, image, title = "New Image", autoflush=False): master = tk.Toplevel(_root) master.protocol("WM_DELETE_WINDOW", self.close) tk.Canvas.__init__(self, master, width = image.getWidth(), height = image.getHeight())...

  • Hi, I need some help finishing the last part of this Python 1 code. The last...

    Hi, I need some help finishing the last part of this Python 1 code. The last few functions are incomplete. Thank you. The instructions were: The program has three functions in it. I’ve written all of break_into_list_of_words()--DO NOT CHANGE THIS ONE. All it does is break the very long poem into a list of individual words. Some of what it's doing will not make much sense to you until we get to the strings chapter, and that's fine--that's part of...

  • In the lectures about lists we have seen some Python code examples that involve the processing of...

    In the lectures about lists we have seen some Python code examples that involve the processing of lists containing weather statistics. The original source of the values shown in the slides was taken from part of the Environment Canada website that serves up historical data: http://climate.weather.gc.ca/historical_data/search_historic_data_e.html    Data can be provied by that website using the Comma Separated Value (CSV) format which is stored in text files normally using a CSV suffix. We will not work directly with such files in...

  • Question 10 Not complete Not graded Generalize the function you wrote previously so you can pass ...

    = Question 10 Not complete Not graded Generalize the function you wrote previously so you can pass in the name of a function as a parameter For example def tabulate_execution_cost(rows, funct_name): Flag question temp, count funct_name (data) To reproduce the previous table, you would call this function using tabulate_execution_cost (10, max_duplicates_in_1ist) For example Test Result tabulate_execution_cost (2, max_duplicates_in_list) NI COUNT| LOGN /N NLOGN /N* *2 13.0 6.5 13 13.0 26 26.0 13.0 tabulate_execution_cost (2, find_difference) COUNT | /LOGN N NLOGN...

  • In this exam, you will design and implement a Python class called 'Date according to the...

    In this exam, you will design and implement a Python class called 'Date according to the following API specifications. • Do NOT use any existing classes in your answer such as datetime. . You will design your class so that it operates correctly on another planet, where the total days in a year, total days in a month, and months per year may be different. For our planet Earth, you will assume that a year has 360 days and all...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT